diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2018-10-30 13:26:45 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-30 13:26:45 -0300 |
commit | 6fb5aa9a2a87c869133d6c43bbe957366abd4d11 (patch) | |
tree | c2538462d40868a4b3c22b64de90ad5ae8ee7ddc | |
parent | 63d26aaddf194769902a8d3d12c71241eeec1612 (diff) | |
download | luarocks-6fb5aa9a2a87c869133d6c43bbe957366abd4d11.tar.gz luarocks-6fb5aa9a2a87c869133d6c43bbe957366abd4d11.tar.bz2 luarocks-6fb5aa9a2a87c869133d6c43bbe957366abd4d11.zip |
Tests: add tests for luarocks.core.sysdetect (#939)
-rw-r--r-- | .travis.yml | 1 | ||||
-rw-r--r-- | spec/sysdetect_spec.lua | 73 |
2 files changed, 74 insertions, 0 deletions
diff --git a/.travis.yml b/.travis.yml index 64d3347a..67eec990 100644 --- a/.travis.yml +++ b/.travis.yml | |||
@@ -11,6 +11,7 @@ cache: | |||
11 | - testrun/testing_server-5.2 | 11 | - testrun/testing_server-5.2 |
12 | - testrun/testing_server-5.3 | 12 | - testrun/testing_server-5.3 |
13 | - testrun/testing_server-2.1 | 13 | - testrun/testing_server-2.1 |
14 | - testrun/binary-samples | ||
14 | 15 | ||
15 | unit_script: &unit_script | 16 | unit_script: &unit_script |
16 | - busted -o gtest --exclude-tags=git,integration --verbose -Xhelper "lua_dir=$PWD/lua_install,travis" | 17 | - busted -o gtest --exclude-tags=git,integration --verbose -Xhelper "lua_dir=$PWD/lua_install,travis" |
diff --git a/spec/sysdetect_spec.lua b/spec/sysdetect_spec.lua new file mode 100644 index 00000000..1e73d5d6 --- /dev/null +++ b/spec/sysdetect_spec.lua | |||
@@ -0,0 +1,73 @@ | |||
1 | |||
2 | local sysdetect = require("luarocks.core.sysdetect") | ||
3 | local lfs = require("lfs") | ||
4 | |||
5 | describe("luarocks.core.sysdetect #unix #unit", function() | ||
6 | |||
7 | setup(function() | ||
8 | os.execute("[ -e binary-samples ] || git clone --depth=1 https://github.com/hishamhm/binary-samples") | ||
9 | os.execute("cd binary-samples && git pull") | ||
10 | end) | ||
11 | |||
12 | local files = { | ||
13 | ["."] = "ignore", | ||
14 | [".."] = "ignore", | ||
15 | ["README.md"] = "ignore", | ||
16 | [".git"] = "ignore", | ||
17 | ["MIT_LICENSE"] = "ignore", | ||
18 | ["anti-disassembler"] = "ignore", | ||
19 | ["elf-Linux-lib-x64.so"] = "ignore", | ||
20 | ["elf-Linux-lib-x86.so"] = "ignore", | ||
21 | |||
22 | ["elf-Linux-x64-bash"] = {"linux", "x86_64"}, | ||
23 | ["elf-Linux-ia64-bash"] = {"linux", "ia_64"}, | ||
24 | ["MachO-OSX-ppc-and-i386-bash"] = {"macosx", "x86"}, | ||
25 | ["MachO-OSX-ppc-openssl-1.0.1h"] = {"macosx", "ppc"}, | ||
26 | ["MachO-iOS-armv7-armv7s-arm64-Helloworld"] = {"macosx", "arm"}, | ||
27 | ["pe-Windows-x64-cmd"] = {"windows", "x86_64"}, | ||
28 | ["MachO-iOS-armv7s-Helloworld"] = {"macosx", "arm"}, | ||
29 | ["elf-Linux-SparcV8-bash"] = {"linux", "sparcv8"}, | ||
30 | ["elf-HPUX-ia64-bash"] = {"hpux", "ia_64"}, | ||
31 | ["MachO-OSX-x64-ls"] = {"macosx", "x86_64"}, | ||
32 | ["pe-Windows-ARMv7-Thumb2LE-HelloWorld"] = {"windows", "armv7l"}, | ||
33 | ["elf-ARMv6-static-gofmt"] = {"sysv", "arm"}, | ||
34 | ["elf-Linux-s390-bash"] = {"linux", "s390"}, | ||
35 | ["elf-Linux-Alpha-bash"] = {"linux", "alpha"}, | ||
36 | ["elf-Linux-hppa-bash"] = {"linux", "hppa"}, | ||
37 | ["elf-Linux-x86_64-static-sln"] = {"linux", "x86_64"}, | ||
38 | ["elf-Linux-Mips4-bash"] = {"linux", "mips"}, | ||
39 | ["elf-ARMv6-dynamic-go"] = {"linux", "arm"}, | ||
40 | ["elf-Linux-SuperH4-bash"] = {"linux", "superh"}, | ||
41 | ["elf-Linux-x86-bash"] = {"linux", "x86"}, | ||
42 | ["elf-Linux-PowerPC-bash"] = {"linux", "ppc"}, | ||
43 | ["libSystem.B.dylib"] = {"macosx", "x86_64"}, | ||
44 | ["MachO-iOS-arm1176JZFS-bash"] = {"macosx", "arm"}, | ||
45 | ["pe-Windows-x86-cmd"] = {"windows", "x86"}, | ||
46 | ["elf-Linux-ARMv7-ls"] = {"linux", "arm"}, | ||
47 | ["elf-Linux-ARM64-bash"] = {"linux", "aarch64"}, | ||
48 | ["MachO-OSX-x86-ls"] = {"macosx", "x86"}, | ||
49 | ["elf-solaris-sparc-ls"] = {"solaris", "sparc"}, | ||
50 | ["elf-solaris-x86-ls"] = {"solaris", "x86"}, | ||
51 | ["pe-mingw32-strip.exe"] = {"windows", "x86"}, | ||
52 | ["elf-OpenBSD-x86_64-sh"] = {"openbsd", "x86_64"}, | ||
53 | ["elf-NetBSD-x86_64-echo"] = {"netbsd", "x86_64"}, | ||
54 | ["elf-FreeBSD-x86_64-echo"] = {"freebsd", "x86_64"}, | ||
55 | ["elf-Haiku-GCC2-ls"] = {"haiku", "x86"}, | ||
56 | ["elf-Haiku-GCC7-WebPositive"] = {"haiku", "x86"}, | ||
57 | ["pe-cygwin-ls.exe"] = {"cygwin", "x86"}, | ||
58 | } | ||
59 | |||
60 | describe("detect_file", function() | ||
61 | it("detects system and processor", function() | ||
62 | for f in lfs.dir("binary-samples") do | ||
63 | if files[f] ~= "ignore" then | ||
64 | assert.table(files[f], "unknown binary " .. f) | ||
65 | local expected_s, expected_p = files[f][1], files[f][2] | ||
66 | local s, p = sysdetect.detect_file("binary-samples/" .. f) | ||
67 | assert.same(expected_s, s, "bad system for " .. f) | ||
68 | assert.same(expected_p, p, "bad processor for " .. f) | ||
69 | end | ||
70 | end | ||
71 | end) | ||
72 | end) | ||
73 | end) | ||