Fix: elf test prog arg checking
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 31 Aug 2015 21:19:20 +0000 (17:19 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 31 Aug 2015 22:27:42 +0000 (18:27 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
tests/ust-elf/prog.c

index bc36b32171c0f5b4ef6cc8e8ec4f3c18117da19d..a39bbc5f02427b7c0c5d4cf03b4c7ddffef30e57 100644 (file)
@@ -26,7 +26,7 @@
 
 #define NUM_ARCH 4
 #define NUM_TESTS_PER_ARCH 11
-#define NUM_TESTS (NUM_ARCH * NUM_TESTS_PER_ARCH)
+#define NUM_TESTS (NUM_ARCH * NUM_TESTS_PER_ARCH) + 1
 
 /*
  * Expected memsz were computed using libelf, build ID and debug link
@@ -116,15 +116,22 @@ int main(int argc, char **argv)
                0xb9, 0x0a, 0xa0, 0xed, 0xd1, 0x41, 0x42, 0xc3, 0x34, 0x85,
                0xfa, 0x27, 0x2e, 0xa9, 0x2f, 0xd2, 0xe4, 0xf7, 0xb6, 0x60
        };
-       const char *TEST_DIR = argv[1];
+       const char *test_dir;
 
        plan_tests(NUM_TESTS);
 
-       test_elf(TEST_DIR, "x86", X86_MEMSZ, X86_BUILD_ID, X86_CRC);
-       test_elf(TEST_DIR, "x86_64", X86_64_MEMSZ, X86_64_BUILD_ID, X86_64_CRC);
-       test_elf(TEST_DIR, "armeb", ARMEB_MEMSZ, ARMEB_BUILD_ID, ARMEB_CRC);
-       test_elf(TEST_DIR, "aarch64_be", AARCH64_BE_MEMSZ, AARCH64_BE_BUILD_ID,
+       ok(argc == 2, "Invoke as: %s <path>", argv[0]);
+       if (argc != 2) {
+               return EXIT_FAILURE;
+       } else {
+               test_dir = argv[1];
+       }
+
+       test_elf(test_dir, "x86", X86_MEMSZ, X86_BUILD_ID, X86_CRC);
+       test_elf(test_dir, "x86_64", X86_64_MEMSZ, X86_64_BUILD_ID, X86_64_CRC);
+       test_elf(test_dir, "armeb", ARMEB_MEMSZ, ARMEB_BUILD_ID, ARMEB_CRC);
+       test_elf(test_dir, "aarch64_be", AARCH64_BE_MEMSZ, AARCH64_BE_BUILD_ID,
                AARCH64_BE_CRC);
 
-       return 0;
+       return EXIT_SUCCESS;
 }
This page took 0.025195 seconds and 5 git commands to generate.