Skip to content

Commit

Permalink
Implement unit test for version command
Browse files Browse the repository at this point in the history
  • Loading branch information
rafael-santiago committed Jan 6, 2022
1 parent 67c3a20 commit 5704457
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/cmd/test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ CUTE_DECLARE_TEST_CASE(regular_using_tests);
CUTE_DECLARE_TEST_CASE(syscall_tracing_mitigation_tests);
CUTE_DECLARE_TEST_CASE(debugging_avoidance_tests);
CUTE_DECLARE_TEST_CASE(strglob_tests);
CUTE_DECLARE_TEST_CASE(version_tests);

#if defined(_WIN32)
CUTE_DECLARE_TEST_CASE(get_ntpath_tests);
Expand All @@ -60,6 +61,7 @@ CUTE_TEST_CASE(cmd_tests)
CUTE_RUN_TEST(get_ntpath_tests);
#endif
CUTE_RUN_TEST(strglob_tests);
CUTE_RUN_TEST(version_tests);
CUTE_RUN_TEST(device_install_tests);
CUTE_RUN_TEST(device_uninstall_tests);
CUTE_RUN_TEST(attach_tests);
Expand All @@ -85,6 +87,19 @@ CUTE_TEST_CASE(cmd_tests)
#endif
CUTE_TEST_CASE_END

CUTE_TEST_CASE(version_tests)
FILE *fp;
char out[1024];
CUTE_ASSERT(zc("version", "> out.txt", NULL) == EXIT_SUCCESS);
fp = fopen("out.txt", "rb");
CUTE_ASSERT(fp != NULL);
memset(out, 0, sizeof(out));
fread(out, 1, sizeof(out), fp);
fclose(fp);
CUTE_ASSERT(strcmp(out, "zc version vx20220000\n") == 0);
remove("out.txt");
CUTE_TEST_CASE_END

CUTE_TEST_CASE(debugging_avoidance_tests)
#if defined(_WIN32)
char *install_cmd = "install --device-driver-path=..\\..\\dev\\zacarias.sys";
Expand Down Expand Up @@ -336,8 +351,12 @@ CUTE_TEST_CASE(regular_using_tests)
remove("passwd");
zacarias_uninstall();

CUTE_ASSERT(zc("version", NULL, NULL) == EXIT_SUCCESS);

CUTE_ASSERT(zacarias_install() == EXIT_SUCCESS);

CUTE_ASSERT(zc("version", NULL, NULL) == EXIT_SUCCESS);

CUTE_ASSERT(zc("attach", "--pwdb=passwd --user=rs --init",
"GiveTheMUleWhatHeWants\nGiveTheMuleWhatHeWants\n") != EXIT_SUCCESS);

Expand Down
2 changes: 1 addition & 1 deletion src/cmd/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ extern struct zc_exec_table_ctx g_command_table[];

extern size_t g_command_table_nr;

#define ZC_VERSION "0.0.1"
#define ZC_VERSION "vx20220000"

#endif

0 comments on commit 5704457

Please sign in to comment.