void node_testimgtool(xml_data_node *node) { xml_data_node *child_node; xml_attribute_node *attr_node; struct imgtooltest_state state; imgtool_init(FALSE, messtest_warn); attr_node = xml_get_attribute(node, "name"); report_testcase_begin(attr_node ? attr_node->value : NULL); memset(&state, 0, sizeof(state)); for (child_node = node->child; child_node; child_node = child_node->next) { if (!strcmp(child_node->name, "createimage")) node_createimage(&state, child_node); else if (!strcmp(child_node->name, "checkfile")) node_checkfile(&state, child_node); else if (!strcmp(child_node->name, "checkdirectory")) node_checkdirectory(&state, child_node); else if (!strcmp(child_node->name, "putfile")) node_putfile(&state, child_node); else if (!strcmp(child_node->name, "deletefile")) node_deletefile(&state, child_node); else if (!strcmp(child_node->name, "createdirectory")) node_createdirectory(&state, child_node); else if (!strcmp(child_node->name, "deletedirectory")) node_deletedirectory(&state, child_node); else if (!strcmp(child_node->name, "recordfreespace")) node_recordfreespace(&state, child_node); else if (!strcmp(child_node->name, "checkfreespace")) node_checkfreespace(&state, child_node); else if (!strcmp(child_node->name, "setattr")) node_setattr(&state, child_node); else if (!strcmp(child_node->name, "checkattr")) node_checkattr(&state, child_node); } report_testcase_ran(state.failed); /* close out any existing partition */ if (state.partition) { imgtool_partition_close(state.partition); state.partition = NULL; } /* close out any existing image */ if (state.image) { imgtool_image_close(state.image); state.image = NULL; } imgtool_exit(); }
void node_testmess(xml_data_node *node) { xml_data_node *child_node; xml_attribute_node *attr_node; int result; pile_init(&command_pile); pool_init(&command_pool); memset(&new_command, 0, sizeof(new_command)); command_count = 0; /* 'driver' attribute */ attr_node = xml_get_attribute(node, "driver"); if (!attr_node) { error_missingattribute("driver"); return; } current_testcase.driver = attr_node->value; /* 'name' attribute */ attr_node = xml_get_attribute(node, "name"); current_testcase.name = attr_node ? attr_node->value : current_testcase.driver; /* 'ramsize' attribute */ attr_node = xml_get_attribute(node, "ramsize"); current_testcase.ram = attr_node ? ram_parse_string(attr_node->value) : 0; /* 'wavwrite' attribute */ attr_node = xml_get_attribute(node, "wavwrite"); current_testcase.wavwrite = attr_node && (atoi(attr_node->value) != 0); /* report the beginning of the test case */ report_testcase_begin(current_testcase.name); current_testcase.commands = NULL; for (child_node = node->child; child_node; child_node = child_node->next) { if (!strcmp(child_node->name, "wait")) node_wait(child_node); else if (!strcmp(child_node->name, "input")) node_input(child_node); else if (!strcmp(child_node->name, "rawinput")) node_rawinput(child_node); else if (!strcmp(child_node->name, "switch")) node_switch(child_node); else if (!strcmp(child_node->name, "screenshot")) node_screenshot(child_node); else if (!strcmp(child_node->name, "checkblank")) node_checkblank(child_node); else if (!strcmp(child_node->name, "imagecreate")) node_imagecreate(child_node); else if (!strcmp(child_node->name, "imageload")) node_imageload(child_node); else if (!strcmp(child_node->name, "memverify")) node_memverify(child_node); else if (!strcmp(child_node->name, "imageverify")) node_imageverify(child_node); else if (!strcmp(child_node->name, "trace")) node_trace(child_node); } memset(&new_command, 0, sizeof(new_command)); new_command.command_type = MESSTEST_COMMAND_END; if (!append_command()) { error_outofmemory(); return; } result = run_test(0, NULL); report_testcase_ran(result); pile_delete(&command_pile); pool_exit(&command_pool); }
void node_testzippath(xml_data_node *node) { xml_attribute_node *attr_node; xml_data_node *first_child_node; xml_data_node *child_node; const char *path; const char *plus; astring *apath = NULL; zippath_directory *directory = NULL; const osd_directory_entry *dirent; const char *type_string; file_error err; UINT64 size; mess_pile pile; core_file *file = NULL; pile_init(&pile); /* name the test case */ report_testcase_begin("zippath"); /* retrieve path */ attr_node = xml_get_attribute(node, "path"); path = (attr_node != NULL) ? attr_node->value : ""; /* retrieve 'plus' - for testing zippath_combine */ attr_node = xml_get_attribute(node, "plus"); if (attr_node != NULL) { plus = attr_node->value; apath = zippath_combine(astring_alloc(), path, plus); report_message(MSG_INFO, "Testing ZIP Path '%s' + '%s' ==> '%s'", path, plus, astring_c(apath)); } else { apath = astring_cpyc(astring_alloc(), path); report_message(MSG_INFO, "Testing ZIP Path '%s'", astring_c(apath)); } /* try doing a file compare */ messtest_get_data(node, &pile); if (pile_size(&pile) > 0) { err = zippath_fopen(astring_c(apath), OPEN_FLAG_READ, &file, NULL); if (err != FILERR_NONE) { report_message(MSG_FAILURE, "Error %d opening file", (int) err); goto done; } if (pile_size(&pile) != core_fsize(file)) { report_message(MSG_FAILURE, "Expected file to be of length %d, instead got %d", (int) pile_size(&pile), (int) core_fsize(file)); goto done; } if (memcmp(pile_getptr(&pile), core_fbuffer(file), pile_size(&pile))) { report_message(MSG_FAILURE, "File sizes match, but contents do not"); goto done; } } /* try doing a directory listing */ first_child_node = xml_get_sibling(node->child, "entry"); if (first_child_node != NULL) { err = zippath_opendir(astring_c(apath), &directory); if (err != FILERR_NONE) { report_message(MSG_FAILURE, "Error %d opening directory", (int) err); goto done; } /* read each directory entry */ while((dirent = zippath_readdir(directory)) != NULL) { /* find it in the list */ for (child_node = first_child_node; child_node != NULL; child_node = xml_get_sibling(child_node->next, "entry")) { attr_node = xml_get_attribute(child_node, "name"); if ((attr_node != NULL) && !strcmp(attr_node->value, dirent->name)) break; } /* did we find the node? */ if (child_node != NULL) { /* check dirent type */ attr_node = xml_get_attribute(child_node, "type"); if (attr_node != NULL) { type_string = dir_entry_type_string(dirent->type); if (mame_stricmp(attr_node->value, type_string)) report_message(MSG_FAILURE, "Expected '%s' to be '%s', but instead got '%s'", dirent->name, attr_node->value, type_string); } /* check size */ attr_node = xml_get_attribute(child_node, "size"); if (attr_node != NULL) { size = atoi(attr_node->value); if (size != dirent->size) report_message(MSG_FAILURE, "Expected '%s' to be of size '%ld', but instead got '%ld'", dirent->name, (long) size, (long) dirent->size); } } else { report_message(MSG_FAILURE, "Unexpected directory entry '%s'", dirent->name); } } } done: pile_delete(&pile); if (apath != NULL) astring_free(apath); if (file != NULL) core_fclose(file); if (directory != NULL) zippath_closedir(directory); }