static int bt_setenv(int argc, char **argv) { BT_u32 total_length = 0; BT_u32 i; for(i = 2; i < argc; i++) { total_length += strlen(argv[i]) + 1; // Add a space after each item. } if(!total_length) { clear_env(argv[1]); return 0; } char *s = BT_kMalloc(total_length+1); if(!s) { bt_printf("No memory could not allocated temporary memory to construct string\n"); return -1; } strcpy(s, ""); for(i = 2; i < argc; i++) { strcat(s, argv[i]); if(i == argc-1) { break; } strcat(s, " "); } BT_ShellSetEnv(argv[1], s, BT_ENV_T_STRING); BT_kFree(s); return 0; }
int main() { int testnumber = 1; int count = 0; if((fp = fopen("ZS_WritebackStoreMode6.log", "w+")) == 0) { fprintf(stderr, " open log file failed!.\n"); return -1; } ZSSetProperty("ZS_STRICT_WRITEBACK", "On"); ZSSetProperty("ZS_MAX_OUTSTANDING_BACKGROUND_FLUSHES", "0"); ZSSetProperty("ZS_CACHE_SIZE", "100000000"); if (ZS_SUCCESS == pre_env()) { for(uint32_t aw = 0; aw < 1; aw++) { count += test_invalid_para(aw); count += test_basic_check(aw); } clear_env(); } fclose(fp); fprintf(stderr, "Test Result:\n"); for(int aw = 0; aw < 1; aw++) { if(0 == aw) { fprintf(stderr, "***** When disable async write: *****\n"); }else{ fprintf(stderr, "***** When enable async write: *****\n"); } for(int i = 0; i < testnumber; i++) { int j_end = (i == 0) ? 6 : 10; fprintf(stderr, "%s\n", testname[i]); for(int j = 0; j < j_end; j++) { if(result[aw][i][j] == 1) { fprintf(stderr, "[mode fifo=%d/persist=%d/evict=%d/writethru=%d] pass\n",mode[j][0],mode[j][1],mode[j][2],mode[j][3]); }else{ fprintf(stderr, "[mode fifo=%d/persist=%d/evict=%d/writethru=%d] fail\n",mode[j][0],mode[j][1],mode[j][2],mode[j][3]); } } } } if(testnumber*2 == count) { fprintf(stderr, "#Test of ZSWritebackStoreMode6 pass!\n"); }else{ fprintf(stderr, "#Test of ZSWritebackStoreMode6 fail!\n"); } return (!(testnumber*2 == count)); }
void script_done_handler(int sig) { int saved_errno = errno; pid_t pid = waitpid((pid_t)(-1), 0, 0); //while (waitpid((pid_t)(-1), 0, WNOHANG) > 0) {} LOG_DEBUG(Scene, "Script done!"); clear_env(pid); errno = saved_errno; }
int main(int ac, char *av[]) { t_env e; e.degree = 0; if (ac != 2) ft_putchar('\n'); else { lexical_analysis(&e, av[1]); reduce_form(&e); resolve_equation(&e); clear_env(&e); } return (0); }
void cupsdInitEnv(void) { /* * Clear existing environment variables... */ clear_env(); #if defined(__APPLE__) /* * Add special voodoo magic for MacOS X - this allows MacOS X * programs to access their bundle resources properly... * * This string is replaced in cupsdStartProcess()... */ cupsdSetString(common_env, "<CFProcessPath>"); num_common_env = 1; #endif /* __APPLE__ */ }
int __ibv_close_device(struct ibv_context *context) { int async_fd = context->async_fd; int cmd_fd = context->cmd_fd; struct verbs_context_exp *context_exp; context_exp = verbs_get_exp_ctx(context); if (context_exp) { struct verbs_device *verbs_device = verbs_get_device(context->device); verbs_device->uninit_context(verbs_device, context); clear_env(context_exp->venv); free(context_exp); } else { context->device->ops.free_context(context); } close(async_fd); close(cmd_fd); return 0; }
int main() { int testnumber = 4; int count = 0; if((fp = fopen("ZS_FlushObject.log", "w+")) == 0) { fprintf(stderr, " open log file failed!.\n"); return -1; } if(ZS_SUCCESS == pre_env()) { for(uint32_t aw = 0; aw < 2; aw++) { // count += test_invalid_cguids(aw); // count += test_invalid_object(aw); // count += test_invalid_key_keylen(aw); count += test_basic_check_1(aw); } clear_env(); } fclose(fp); fprintf(stderr, "Test Result:\n"); for(int aw = 0; aw < 2; aw++) { if(0 == aw) { fprintf(stderr, "***** When disable async write: *****\n"); } else { fprintf(stderr, "***** When enable async write: *****\n"); } for(int i = 0; i < testnumber; i++) { if(NULL != testname[i]) { fprintf(stderr, "%s\n", testname[i]); for(int j = 0; j < 3; j++) { if(result[aw][i][j] == 1) { fprintf(stderr, "[durability type = %d] pass\n",j); } else { fprintf(stderr, "[durability type = %d] fail\n",j); } } } } } if(1*2 == count) { fprintf(stderr, "#Test of ZSFlushObject pass!\n"); fprintf(stderr, "#The related test script is ZS_FlushObject.c\n"); fprintf(stderr, "#If you want, you can check test details in ZS_FlushObject.log\n"); } else { fprintf(stderr, "#Test of ZSFlushObject fail!\n"); fprintf(stderr, "#The related test script is ZS_FlushObject.c\n"); fprintf(stderr, "#If you want, you can check test details in ZS_FlushObject.log\n"); } return (!(1*2 == count)); }
static int32_t mgr1() { ZS_status_t ret = ZS_SUCCESS; fprintf(fp, "%s", "****** Test 1 *****\n"); /* * Init ZS */ ret = pre_env(); if (ZS_SUCCESS != ret) { fprintf(fp, "pre_env failed with err=%s\n", ZSStrError(ret)); return -1; } /* * Create a container */ uint32_t flag = ZS_CTNR_CREATE; //ZS_CTNR_RO_MODE uint32_t dura = ZS_DURABILITY_PERIODIC; char cname[1024] = {'\0'}; uint32_t i; int32_t r = 0; int32_t count = 0; sprintf(cname, "test_%d", 0); do { ret = OpenContainer(cname, flag, dura, &cguid); /* * Start high frequency I/O */ for (i = 0; i < MAX_ITERATION; i++) { r = rand() % 16 + 1; if (0 == (r % 7)) { fprintf(fp, "Random failure at %d\n", r); goto exit_mgr1; } ret = io(); if (ZS_SUCCESS != ret) { fprintf(fp, "io failed with err=%s\n", ZSStrError(ret)); goto exit_mgr1; } } ret = DeleteContainer(cguid); if (ZS_SUCCESS != ret) { fprintf(fp, "DeleteContainer failed with err=%s\n", ZSStrError(ret)); goto exit_mgr1; } count++; } while (count < 5); exit_mgr1: /* * Start graceful shutdown */ fprintf(fp, "%s", "Starting graceful shutdown\n"); ret = clear_env(); fprintf(fp, "Shutdown returned %s:\n", ZSStrError(ret)); if (ZS_SUCCESS != ret) { fprintf(fp, "%s", "Graceful shutdown test1 failed\n"); return 1; } /* * Attempt another shutdown */ fprintf(fp, "%s", "Attempt another shutdown\n"); ret = ZSShutdown(zs_state); fprintf(fp, "Next shutdown returned %s:\n", ZSStrError(ret)); if (ZS_SUCCESS == ret) { fprintf(fp, "%s", "Next shutdown test2 failed\n"); return 1; } /* * Perform I/O and container ops after shutdown * It should fail */ ret = io(); fprintf(fp, "Post shutdown: I/O failed with %s\n", ZSStrError(ret)); if (ZS_SUCCESS == ret) { fprintf(fp, "%s", "Post shutdown: I/O test3 failed\n"); return 1; } /* * Perform container ops: It should fail */ ret = container_ops(cname, flag, dura); fprintf(fp, "Post shutdown: container ops returns %s\n", ZSStrError(ret)); if (ZS_SUCCESS == ret) { fprintf(fp, "%s", "Post shutdown: container ops test4 failed\n"); return 1; } return 0; }