/* System function tests */ #include #include "test.h" static int counter = 0; static void handler(int signal) { counter++; } int main(void) { vlist *proc; int t; TEST_START("system"); TEST("checking existence", v_test("/usr/bin", V_TEST_EXISTS)); TEST("checking file", v_test("/bin/ls", V_TEST_FILE)); TEST("checking directory", v_test("/usr/local/bin", V_TEST_DIR)); TEST("getting filename part", V_STREQ(v_filename("/usr/local/bin"), "bin")); TEST("getting dirname part", V_STREQ(v_dirname("/usr/local/bin"), "/usr/local")); TEST("getting process information", (proc = v_procinfo()) != NULL); v_freeze_file(proc, TEST_OUTPUT); TEST("date parsing", (t = v_parse_date("tomorrow")) > 0); v_signal(SIGUSR1, handler); kill(getpid(), SIGUSR1); TEST("signal handlers", counter > 0); TEST_FINISH; }