int main( int argc , char ** argv) { util_install_signals(); { const char * file = argv[1]; test_fortio_is_instance( file ); test_fortio_safe_cast( file ); test_assert_util_abort("fortio_safe_cast", test_fortio_unsafe_cast, NULL); test_existing_read( file ); test_not_existing_read( ); test_open_close_read( file ); test_wrapper( file ); test_fread_truncated_head(); test_fread_truncated_data(); test_fread_truncated_tail(); test_fread_invalid_tail(); test_fseek(); test_at_eof(); test_write( "/tmp/path/does/not/exist" , false ); { test_work_area_type * work_area = test_work_area_alloc("ecl_fortio.write" ); util_make_path("path"); test_write( "path/file.x" , true ); test_work_area_free( work_area ); } exit(0); } }
static void cl_test( hpx::opencl::device local_device, hpx::opencl::device remote_device ) { hpx::opencl::buffer buffer = remote_device.create_buffer(CL_MEM_READ_WRITE, DATASIZE); hpx::opencl::buffer buffer2 = remote_device.create_buffer(CL_MEM_READ_WRITE, DATASIZE); hpx::opencl::buffer remote_buffer = local_device.create_buffer(CL_MEM_READ_WRITE, DATASIZE); // test if buffer initialization worked size_t buffer_size = buffer.size().get(); HPX_TEST_EQ(buffer_size, DATASIZE); // test if buffer can be written to test_write(props01, moddata, refdata01); test_write(props02, moddata, refdata02); test_write(props03, moddata, refdata03); test_write(props04, moddata, refdata04); test_write(props05, moddata2, refdata05); }
static void test(int step) { if (test_sync_trivial) { test_sync_trivial_run(step); } if (test_write_) { test_write(512); } if (test_leak_malloc) { leak_malloc(SLICE, step); } if (test_leak_calloc) { leak_calloc(SLICE, step); } if (test_leak_realloc) { leak_realloc(SLICE, step); } if (test_sync) { test_sync_step(step); } if (test_dl_) { test_dl(step); } if (test_pi) { int num_steps = 1000000; printf("Calculating PI (%d steps)...\n", num_steps); calc_pi(num_steps); } }
int main(int argc, char *argv[]) { FILE *f = fopen(TMP_FILE, "w"); test t; t.f1 = 34; t.f2_len = 4; uint32_t arr[] = {4,18,29,3}; t.f2 = arr; test_write(&t, f); fclose(f); FILE *in = fopen(TMP_FILE, "r"); test t2; test_read_new(&t2, in); assert(t2.f1 == 34); assert(t2.f2_len == 4); assert(t2.f2[0] == 4); assert(t2.f2[1] == 18); assert(t2.f2[2] == 29); assert(t2.f2[3] == 3); test_free(&t2); fclose(in); execl("rm", "rm", "-f", TMP_FILE, NULL); return 0; }
void start_test(int id) { uint i; int error,lock_type; MI_ISAMINFO isam_info; MI_INFO *file,*file1,*file2=0,*lock; if (use_log) mi_log(1); if (!(file1=mi_open(filename,O_RDWR,HA_OPEN_WAIT_IF_LOCKED)) || !(file2=mi_open(filename,O_RDWR,HA_OPEN_WAIT_IF_LOCKED))) { fprintf(stderr,"Can't open isam-file: %s\n",filename); exit(1); } if (key_cacheing && rnd(2) == 0) init_key_cache(dflt_key_cache, KEY_CACHE_BLOCK_SIZE, 65536L, 0, 0); printf("Process %d, pid: %d\n",id,getpid()); fflush(stdout); for (error=i=0 ; i < tests && !error; i++) { file= (rnd(2) == 1) ? file1 : file2; lock=0 ; lock_type=0; if (rnd(10) == 0) { if (mi_lock_database(lock=(rnd(2) ? file1 : file2), lock_type=(rnd(2) == 0 ? F_RDLCK : F_WRLCK))) { fprintf(stderr,"%2d: start: Can't lock table %d\n",id,my_errno); error=1; break; } } switch (rnd(4)) { case 0: error=test_read(file,id); break; case 1: error=test_rrnd(file,id); break; case 2: error=test_write(file,id,lock_type); break; case 3: error=test_update(file,id,lock_type); break; } if (lock) mi_lock_database(lock,F_UNLCK); } if (!error) { mi_status(file1,&isam_info,HA_STATUS_VARIABLE); printf("%2d: End of test. Records: %ld Deleted: %ld\n", id,(long) isam_info.records, (long) isam_info.deleted); fflush(stdout); } mi_close(file1); mi_close(file2); if (use_log) mi_log(0); if (error) { printf("%2d: Aborted\n",id); fflush(stdout); exit(1); } }
int main(void) { board_init(); if (test_erase() == STATUS_OK) { /* Toggle LED to indicate success */ gpio_toggle_pin(LED_PIN_0); } if (test_write() == STATUS_OK) { /* Toggle LED to indicate success */ gpio_toggle_pin(LED_PIN_1); } if (test_atomic_write() == STATUS_OK) { /* Toggle LED to indicate success */ gpio_toggle_pin(LED_PIN_2); } if (test_split_write() == STATUS_OK) { /* Toggle LED to indicate success */ gpio_toggle_pin(LED_PIN_3); } if (test_erase_bytes() == STATUS_OK) { /* Toggle LED to indicate success */ gpio_toggle_pin(LED_PIN_4); } /* Toggle LED to indicate that we are done */ gpio_toggle_pin(LED_PIN_7); while (true) {} }
int main(int ac, char **av) { int afd, fd; aio_context_t ctx = 0; char const *testfn = "/tmp/eventfd-aio-test.data"; fprintf(stdout, "creating an eventfd ...\n"); if ((afd = eventfd(0)) == -1) { perror("eventfd"); return 2; } fprintf(stdout, "done! eventfd = %d\n", afd); if (io_setup(TESTFILE_SIZE / IORTX_SIZE + 256, &ctx)) { perror("io_setup"); return 3; } if ((fd = open(testfn, O_RDWR | O_CREAT, 0644)) == -1) { perror(testfn); return 4; } ftruncate(fd, TESTFILE_SIZE); fcntl(afd, F_SETFL, fcntl(afd, F_GETFL, 0) | O_NONBLOCK); test_write(ctx, fd, TESTFILE_SIZE, afd); test_read(ctx, fd, TESTFILE_SIZE, afd); io_destroy(ctx); close(fd); close(afd); remove(testfn); return 0; }
int main(int argc, char* argv[]) { if (argc < 2) { goto help; } if (strcmp(argv[1], "create") == SHM_OK) { return test_creat(); } else if (strcmp(argv[1], "write") == SHM_OK) { return test_write(); } else if (strcmp(argv[1], "read") == SHM_OK) { return test_read(); } else if (strcmp(argv[1], "delete") == SHM_OK) { return test_delete(); } help: printf("Usage: shm COMMAND\n\n" "The most used commands are:\n" "create Create a share memory\n" "write Write something into the share memory\n" "read Read something from the share memory\n" "delete Delete the share memory\n" ); return SHM_FAILED; }
int main() { pc.printf("Test the Stream class\n"); printf("connected: %s\n", (semihost_connected()) ? ("Yes") : ("No")); char mac[16]; mbed_mac_address(mac); printf("mac address: %02x,%02x,%02x,%02x,%02x,%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); LocalFileSystem local("local"); FILE *f; char* str = TEST_STRING; char* buffer = (char*) malloc(sizeof(unsigned char)*strlen(TEST_STRING)); int str_len = strlen(TEST_STRING); // Write f = test_open("w"); test_write(f, str, str_len); test_close(f); // Read f = test_open("r"); test_read(f, buffer, str_len); test_close(f); // Check the two strings are equal notify_completion((strncmp(buffer, str, str_len) == 0)); }
int main(int argc, const char* argv[]) { if (argc != 2) { usage(argv[0]); return 1; } if (!test_write(argv[1])) { return 1; } if (!test_read(argv[1])) { return 1; } if (!test_modify(argv[1])) { return 1; } return 0; }
int main (int argc, char ** argv) { printf ("RENAME TESTS\n"); printf ("==================\n\n"); init (argc, argv); test_withoutConfig (); test_simpleCutOnGet (); test_simpleCutRestoreOnSet (); test_metaCutOnGet (); test_metaConfigTakesPrecedence (); test_rebaseOfNewKeys (); test_addNewBaseToParentKey (); test_keyCutNamePart (); test_toUpper (); test_toLower (); test_mixCase (); test_replaceString (); test_write (); test_write2 (); printf ("\ntest_rename RESULTS: %d test(s) done. %d error(s).\n", nbTest, nbError); return nbError; }
int main() { MBED_HOSTTEST_TIMEOUT(20); MBED_HOSTTEST_SELECT(default_auto); MBED_HOSTTEST_DESCRIPTION(Semihost file system); MBED_HOSTTEST_START("MBED_A2"); pc.printf("Test the Stream class\n"); printf("connected: %s\n", (semihost_connected()) ? ("Yes") : ("No")); char mac[16]; mbed_mac_address(mac); printf("mac address: %02x,%02x,%02x,%02x,%02x,%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); LocalFileSystem local("local"); FILE *f; char *str = TEST_STRING; char *buffer = (char *)malloc(sizeof(unsigned char) * strlen(TEST_STRING)); int str_len = strlen(TEST_STRING); // Write f = test_open("w"); test_write(f, str, str_len); test_close(f); // Read f = test_open("r"); test_read(f, buffer, str_len); test_close(f); // Check the two strings are equal MBED_HOSTTEST_RESULT((strncmp(buffer, str, str_len) == 0)); }
int main(void) { fprintf(stderr, "%s\n", __FILE__); unlink("./data.lsmdb"); unlink("./data.lsmdb-lock"); LSMDB_env *env; chk( lsmdb_env_create(&env) ); chk( lsmdb_env_set_mapsize(env, MAP_SIZE) ); chk( lsmdb_env_open(env, "./data.lsmdb", MDB_NOSUBDIR | (!SYNC * MDB_NOSYNC), 0600) ); /* MDB_dbi dbi; { MDB_txn *txn; chk( mdb_txn_begin(env, NULL, MDB_RDWR, &txn) ); chk( mdb_dbi_open(txn, NULL, 0, &dbi) ); chk( mdb_txn_commit(txn) ); }*/ test_write(env); if(READ) test_read(env); lsmdb_env_close(env); return 0; }
int main() { test_read(); test_write(); printf("\n \e[32m\u2713 \e[90mok\e[0m\n\n"); return 0; }
int main() { SDFileSystem sd(p11, p12, p13, p14, "sd"); FILE *f; char* str = TEST_STRING; char* buffer = (char*) malloc(sizeof(unsigned char)*strlen(TEST_STRING)); int str_len = strlen(TEST_STRING); printf("Write files\n"); char filename[32]; for (int i=0; i<10; i++) { sprintf(filename, "/sd/test_%d.txt", i); printf("Creating file: %s\n", filename); f = test_open(filename, "w"); test_write(f, str); test_close(f); } printf("List files:\n"); DIR *d = opendir("/sd"); if (d == NULL) { printf("Error opening directory\n"); notify_completion(false); } struct dirent *p; while((p = readdir(d)) != NULL) { printf("%s\n", p->d_name); } closedir(d); notify_completion(true); }
int main( int argc , char ** argv) { const char * file = argv[1]; test_existing_read( file ); test_not_existing_read( ); test_open_close_read( file ); test_wrapper( file ); test_write( "/tmp/path/does/not/exist" , false ); { test_work_area_type * work_area = test_work_area_alloc("ecl_fortio.write" ); util_make_path("path"); test_write( "path/file.x" , true ); test_work_area_free( work_area ); } exit(0); }
int main(int argc, char** argv) { vsipl init(argc, argv); test_write(); test_read(); }
int do_pll_alter (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { char c = '\0'; pll_freq_t pll_freq; if (argc < 2) { cmd_usage(cmdtp); goto ret; } for (pll_freq = PLL_ebc20; pll_freq < PLL_TOTAL; pll_freq++) if (!strcmp(pll_name[pll_freq], argv[1])) break; switch (pll_freq) { case PLL_ebc20: case PLL_333: case PLL_4001: case PLL_4002: case PLL_533: case PLL_600: EEPROM_ALTER_FREQ(pll_freq); break; case PLL_666: /* not support */ printf("Choose this option will result in a boot failure." "\nContinue? (Y/N): "); c = getc(); putc('\n'); if ((c == 'y') || (c == 'Y')) { EEPROM_ALTER_FREQ(pll_freq); break; } goto ret; case RCONF: pll_debug(EEPROM_CONF_OFFSET); goto ret; case WTEST: printf("DEBUG: write test\n"); test_write(); goto ret; default: printf("Invalid options\n\n"); cmd_usage(cmdtp); goto ret; } printf("PLL set to %s, " "reset the board to take effect\n", pll_name[pll_freq]); PLL_DEBUG; ret: return 0; }
int main() { try { test_write(); } catch (const std::exception& e) { std::cout << e.what() << std::endl; return 1; } return 0; }
int main() { #if defined(TARGET_KL25Z) SDFileSystem sd(PTD2, PTD3, PTD1, PTD0, "sd"); #elif defined(TARGET_nRF51822) //SDFileSystem sd(p20, p22, p25, p24, "sd"); SDFileSystem sd(p12, p13, p15, p14, "sd"); #elif defined(TARGET_NUCLEO_F030R8) || \ defined(TARGET_NUCLEO_F072RB) || \ defined(TARGET_NUCLEO_F091RC) || \ defined(TARGET_NUCLEO_F103RB) || \ defined(TARGET_NUCLEO_F302R8) || \ defined(TARGET_NUCLEO_F303RE) || \ defined(TARGET_NUCLEO_F334R8) || \ defined(TARGET_NUCLEO_F401RE) || \ defined(TARGET_NUCLEO_F411RE) || \ defined(TARGET_NUCLEO_L053R8) || \ defined(TARGET_NUCLEO_L152RE) SDFileSystem sd(D11, D12, D13, D10, "sd"); #elif defined(TARGET_LPC1768_MINI_DK2) SDFileSystem sd(SD_SDI, SD_SDO, SD_SCK, SD_CS, "sd"); #else SDFileSystem sd(p11, p12, p13, p14, "sd"); #endif led2 = 1; wait(0.5); FILE *f; char *str = TEST_STRING; char *buffer = (char *)malloc(sizeof(unsigned char) * strlen(TEST_STRING)); int str_len = strlen(TEST_STRING); printf("Write files\n"); char filename[32]; for (int i = 0; i < 10; i++) { sprintf(filename, "/sd/test_%d.txt", i); printf("Creating file: %s\n", filename); f = test_open(filename, "w"); led2 = 0; test_write(f, str); test_close(f); } printf("List files:\n"); DIR *d = opendir("/sd"); if (d == NULL) { printf("Error opening directory\n"); notify_completion(false); } struct dirent *p; while ((p = readdir(d)) != NULL) printf("%s\n", p->d_name); closedir(d); notify_completion(true); }
int main(void) { board_init(); // Initialize graphics library gfx_mono_init(); // Enable backlight ioport_set_pin_high(LCD_BACKLIGHT_ENABLE_PIN); gfx_mono_draw_string("Tests successful: \r\n1 2 3 4 5", 0, 0, &sysfont); if (test_erase() == STATUS_OK) { gfx_mono_draw_string("OK", 0, 2 * SYSFONT_HEIGHT + 1, &sysfont); } else { gfx_mono_draw_string("ERR", 0, 2 * SYSFONT_HEIGHT + 1, &sysfont); } if (test_write() == STATUS_OK) { gfx_mono_draw_string("OK", 4 * SYSFONT_WIDTH, 2 * SYSFONT_HEIGHT + 1, &sysfont); } else { gfx_mono_draw_string("ERR", 4 * SYSFONT_WIDTH, 2 * SYSFONT_HEIGHT + 1, &sysfont); } if (test_atomic_write() == STATUS_OK) { gfx_mono_draw_string("OK", 8 * SYSFONT_WIDTH, 2 * SYSFONT_HEIGHT + 1, &sysfont); } else { gfx_mono_draw_string("ERR", 8 * SYSFONT_WIDTH, 2 * SYSFONT_HEIGHT + 1, &sysfont); } if (test_split_write() == STATUS_OK) { gfx_mono_draw_string("OK", 12 * SYSFONT_WIDTH, 2 * SYSFONT_HEIGHT + 1, &sysfont); } else { gfx_mono_draw_string("ERR", 12 * SYSFONT_WIDTH, 2 * SYSFONT_HEIGHT + 1, &sysfont); } if (test_erase_bytes() == STATUS_OK) { gfx_mono_draw_string("OK", 16 * SYSFONT_WIDTH, 2 * SYSFONT_HEIGHT + 1, &sysfont); } else { gfx_mono_draw_string("ERR", 16 * SYSFONT_WIDTH, 2 * SYSFONT_HEIGHT + 1, &sysfont); } while (true) {} }
int main(int argc, char** argv) { vsipl init(argc, argv); test_write(); test_read_matrix(); test_read_vector(); }
int runTests() { int passed = 1; char newchar; passed &= lsTest(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= test_cat(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= test_read(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= test_write(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= cdTest(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= chmodTest(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= mkdirTest(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= touchTest(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= linkTest(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= rmdirTest(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= pwdTest(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= cpTest(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= mvTest(); printf("\nEnter a char to continue!\n"); scanf(" %c", &newchar); passed &= lseekTest(); if (passed == 1) { printf("\n\nEVERYTHING PASSED\n\n"); } else { printf("\n\nNOT EVERYTHING PASSED\n\n"); } }
/** * argv[1]: file operation * argv[2]: file to test (with path) * argv[3]: file to test (without path) */ int main(int argc, char *argv[]) { if (argc != 4) { fprintf(stderr, "wrong argument number\n"); return 1; } filepath = argv[2]; filename = argv[3]; /* create file and get the initial inode version */ fd = creat(argv[2], O_RDWR); if (fd == -1) { fprintf(stderr, "failed to create file: %s\n", argv[2]); return 1; } old_inode_version = get_inode_version(); if (strcmp(argv[1], "create") == 0) { printf("%d\n", old_inode_version); return 0; } else if (strcmp(argv[1], "chmod") == 0) { test_chmod(); } else if (strcmp(argv[1], "chown") == 0) { test_chown(); } else if (strcmp(argv[1], "read") == 0) { test_read(); } else if (strcmp(argv[1], "write") == 0) { test_write(); } else if (strcmp(argv[1], "mmap_read") == 0) { test_mmap_read(); } else if (strcmp(argv[1], "mmap_write") == 0) { test_mmap_write(); } else { fprintf(stderr, "wrong file operation: %s\n", argv[1]); return 1; } new_inode_version = get_inode_version(); #if 0 fprintf(stderr, "test_inode_version: old - %d\n", old_inode_version); fprintf(stderr, "test_inode_version: new - %d\n", new_inode_version); #endif /* wrong inode version, test failed */ if (new_inode_version <= old_inode_version) return 1; printf("%d\n", new_inode_version); close(fd); return 0; }
static void test_write_wantsignal(const char *testname, int sock1, int sock2) { if (shutdown(sock2, SHUT_WR) < 0) err(-1, "%s: shutdown", testname); signal_setup(testname); test_write(testname, sock2); if (!got_signal()) errx(-1, "%s: write: didn't receive SIGPIPE", testname); close(sock1); close(sock2); }
int main(int argc, char *argv[]) { char *s = strrchr(argv[0], '/'); s += 1; printf("%s\n", s); if (!strcmp(s, "write")) test_write(); if (!strcmp(s, "read")) test_read(); return 0; }
/* * Main routine */ int main(int argc, char *argv[]) { char test_str[] = "test stdout...\n\n"; syslog(LOG_INFO, "\nfileio: fs test program\n"); /* Wait 1 sec until loading fs server */ timer_sleep(1000, 0); /* * Prepare to use a file system. */ fslib_init(); /* * Mount file systems */ mount("", "/", "ramfs", 0, NULL); mkdir("/dev", 0); mount("", "/dev", "devfs", 0, NULL); /* device */ mkdir("/boot", 0); mount("/dev/ram0", "/boot", "arfs", 0, NULL); /* archive */ mkdir("/tmp", 0); /* * Prepare stdio */ open("/dev/tty", O_RDWR); /* stdin */ dup(0); /* stdout */ dup(0); /* stderr */ /* Test device write */ write(STDOUT_FILENO, test_str, strlen(test_str)); test_write(); cat_file(); /* test read/write */ test_invalid(); /* test invalid request */ test_read(); /* test read loop */ test_open(); /* test open/close loop */ /* * Disconnect from a file system. */ fslib_exit(); return 0; }
static void test_prot(void *p, int prot) { int r, w; verbose_printf("Reading.."); r = test_read(p); verbose_printf("%d\n", r); verbose_printf("Writing.."); w = test_write(p, RANDOM_CONSTANT); verbose_printf("%d\n", w); if (prot & PROT_READ) { if (r != 0) FAIL("read failed on mmap(prot=%x)", prot); } else { if (r != -1) FAIL("read succeeded on mmap(prot=%x)", prot); } if (prot & PROT_WRITE) { switch (w) { case -1: FAIL("write failed on mmap(prot=%x)", prot); break; case 0: break; case 1: FAIL("write mismatch on mmap(prot=%x)", prot); break; default: TEST_BUG(); } } else { switch (w) { case -1: break; case 0: FAIL("write succeeded on mmap(prot=%x)", prot); break; case 1: FAIL("write mismatch on mmap(prot=%x)", prot); break; default: TEST_BUG(); } } }
int main(int argc, char **argv) { int fd; if (argc != 2) usage(argv[0]); printf("Initalizing OBD device at '%s'...\n", argv[1]); ERR(fd = obd_init(argv[1]), -1); test_write(fd); test_read(fd); obd_shutdown(fd); return 0; }
static void test_write_dontsignal(const char *testname, int sock1, int sock2) { int i; i = 1; if (setsockopt(sock2, SOL_SOCKET, SO_NOSIGPIPE, &i, sizeof(i)) < 0) err(-1, "%s: setsockopt(SOL_SOCKET, SO_NOSIGPIPE)", testname); if (shutdown(sock2, SHUT_WR) < 0) err(-1, "%s: shutdown", testname); signal_setup(testname); test_write(testname, sock2); if (got_signal()) errx(-1, "%s: write: got SIGPIPE", testname); close(sock1); close(sock2); }