void dup2Test() { if (-1 == dup2(1, 2)) { perror("dup2 error"); return; } errorTest(); }
int main(int argc, char **argv) { if (argc == 1) { coverage(); return 0; } if (argc == 2 && strcmp(argv[1], "err")==0) { errorTest(); return 0; } testFile(argv[1]); return 0; }
/** * Runs the test suite. */ int runTests() { int hr = SUCCESS; #ifndef EXTRA_CREDIT #ifndef COMPETITION_TEST FILE *f_ls_base; #else FILE *f_ls_compTest; #endif #endif #ifdef EXTRA_CREDIT FILE *f_ls_extra_credit; #endif #if COMPETITION FILE *f_ls_competition; f_ls_competition = fopen("competition.ls", "w"); #endif RUN_TEST(initDiskTest()); #ifndef EXTRA_CREDIT #ifndef COMPETITION_TEST f_ls_base = fopen("base.ls", "w"); f_ls = f_ls_base; RUN_TEST(initFSTest()); RUN_TEST(createSimpleFileTest()); RUN_TEST(createSimpleFileTest()); RUN_TEST(createSimpleFileWriteReadTest()); RUN_TEST(singleBigFileTest()); RUN_TEST(multipleFilesTest()); RUN_TEST(createFolderTest()); RUN_TEST(multipleFoldersTest()); RUN_TEST(appendFileTest()); RUN_TEST(multipleOpenFilesTest()); RUN_TEST(nestedFoldersTest()); RUN_TEST(errorTest()); #else f_ls_compTest = fopen("compTest.ls", "w"); f_ls = f_ls_compTest; RUN_TEST(customTest()); #endif #endif #ifdef EXTRA_CREDIT f_ls_extra_credit = fopen("extra_credit.ls", "w"); f_ls = f_ls_extra_credit; RUN_TEST(removeTest()); #endif // NOTE: We're not using this competition code this year. #if COMPETITION f_ls = f_ls_competition; RUN_TEST(perfTest()); #endif Fail: #ifndef EXTRA_CREDIT #ifndef COMPETITION_TEST fclose(f_ls_base); #else fclose(f_ls_compTest); #endif #endif #ifdef EXTRA_CREDIT fclose(f_ls_extra_credit); #endif #if COMPETITION fclose(f_ls_competition); #endif return hr; }
int main(int argc, char *argv[]) { GError *error = NULL; GOptionContext *context; atexit(safeExit); // init log system gp_log_init(APP_LOGFILE); // Get some application/host data appInfo(); /* if (isAppRunning()) { printf("Application is already running\n"); exit(0); g_critical("Application is already running"); } */ // parse command line arguments context = g_option_context_new (APP_DESCRIPTION); g_option_context_add_main_entries (context, entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_print ("option parsing failed: %s\n", error->message); exit (1); } // enable verbose mode if (opt_verbose) { gp_log_set_verbose(TRUE); } g_message("Program start\n"); // print version information if (opt_version) { printf("Program version %s\nBuild ("__DATE__" "__TIME__")\n", APP_VERSION); exit(0); } // Error Test if (opt_errorTest) { errorTest(); exit(0); } // thread test if (opt_threadTest) { threadTest(); exit(0); } // info test if (opt_info) { infoTest(); exit(0); } // daemon test if (opt_daemonTest) { daemonTest(); exit(0); } // queue test if (opt_queueTest) { queueTest(); exit(0); } // pipe test if (opt_pipeTest) { pipeTest(); exit(0); } // domain socket test if (opt_domainTest) { domainTest(); exit(0); } return 0; }