render_config_delta_cache::render_config_delta_cache(const config_file &file)
{
	if (file.empty())
		return;

	const pugi::xml_document *config_xml_doc = reinterpret_cast<const pugi::xml_document *>(file.get_config_xml());
	const pugi::xpath_node_set font_render_font_nodes = config_xml_doc->select_nodes(L"/gdipp/server/render/font");
	for (pugi::xpath_node_set::const_iterator node_iter = font_render_font_nodes.begin(); node_iter != font_render_font_nodes.end(); ++node_iter)
	{
		const pugi::xml_node curr_node = node_iter->node();
		font_config_criteria curr_criteria(&curr_node);
		render_config_delta curr_config_delta;
		curr_config_delta.parse(&curr_node);
		_font_config_deltas.push_front(std::pair<font_config_criteria, render_config_delta>(curr_criteria, curr_config_delta));			
	}

	const pugi::xpath_node_set proc_render_font_nodes = config_xml_doc->select_nodes(L"/gdipp/server/render/process");
	for (pugi::xpath_node_set::const_iterator node_iter = proc_render_font_nodes.begin(); node_iter != proc_render_font_nodes.end(); ++node_iter)
	{
		const pugi::xml_node curr_node = node_iter->node();
		proc_config_criteria curr_criteria(&curr_node);
		render_config_delta curr_config_delta;
		curr_config_delta.parse(&curr_node);
		_proc_config_deltas.push_front(std::pair<proc_config_criteria, render_config_delta>(curr_criteria, curr_config_delta));			
	}
}
示例#2
0
int32_t
GCConfigTest::verifyVerboseGC(pugi::xpath_node_set verboseGCs)
{
	OMRPORT_ACCESS_FROM_OMRPORT(gcTestEnv->portLib);
	int32_t rt = 0;
	uintptr_t seq = 1;
	size_t numOfNode = verboseGCs.size();
	bool *isFound = (bool *)omrmem_allocate_memory(sizeof(int32_t) * numOfNode, OMRMEM_CATEGORY_MM);
	if (NULL == isFound) {
		rt = 1;
		omrtty_printf("%s:%d Failed to allocate native memory.\n", __FILE__, __LINE__);
		goto done;
	}
	for (size_t i = 0; i < numOfNode; i++) {
		isFound[i] = false;
	}

	/* Loop through multiple files if rolling log is enabled */
	do {
		pugi::xml_document verboseDoc;
		if (0 == numOfFiles) {
			verboseDoc.load_file(verboseFile);
			omrtty_printf("Parsing verbose log %s:\n", verboseFile);
#if defined(OMRGCTEST_PRINTFILE)
			printFile(verboseFile);
#endif
		} else {
			char currentVerboseFile[MAX_NAME_LENGTH];
			omrstr_printf(currentVerboseFile, MAX_NAME_LENGTH, "%s.%03zu", verboseFile, seq++);
			pugi::xml_parse_result result = verboseDoc.load_file(currentVerboseFile);
			if (pugi::status_file_not_found == result.status) {
				break;
			}
			omrtty_printf("Parsing verbose log %s:\n", currentVerboseFile);
#if defined(OMRGCTEST_PRINTFILE)
			printFile(currentVerboseFile);
#endif
		}

		/* verify each xquery criteria */
		int32_t i = 0;
		for (pugi::xpath_node_set::const_iterator it = verboseGCs.begin(); it != verboseGCs.end(); ++it) {
			const char *xpathNodesStr = it->node().attribute("xpathNodes").value();
			const char *xqueryStr = it->node().attribute("xquery").value();

			pugi::xpath_query resultQuery(xqueryStr);
			if (!resultQuery) {
				rt = 1;
				omrtty_printf("%s:%d Invalid xquery string \"%s\" specified in configuration file.\n", __FILE__, __LINE__, xqueryStr);
				goto done;
			}

			pugi::xpath_query nodeQuery(xpathNodesStr);
			if (!nodeQuery) {
				rt = 1;
				omrtty_printf("%s:%d Invalid xpathNodes string \"%s\" specified in configuration file.\n", __FILE__, __LINE__, xpathNodesStr);
				goto done;
			}

			pugi::xpath_node_set xpathNodes = nodeQuery.evaluate_node_set(verboseDoc);
			if (!xpathNodes.empty()) {
				bool isPassed = true;
				omrtty_printf("Verifying xquery \"%s\" on xpath \"%s\":\n", xqueryStr, xpathNodesStr);
				for (pugi::xpath_node_set::const_iterator it = xpathNodes.begin(); it != xpathNodes.end(); ++it) {
					pugi::xml_node node = it->node();
					if (!resultQuery.evaluate_boolean(node)) {
						rt = 1;
						isPassed = false;
						omrtty_printf("\t*FAILED* on node <%s", node.name());
						for (pugi::xml_attribute attr = node.first_attribute(); attr; attr = attr.next_attribute()) {
							omrtty_printf("\t%s=%s", attr.name(), attr.value());
						}
						omrtty_printf(">\n");
					}
				}
				if (isPassed) {
					omrtty_printf("*PASSED*\n");
				}
				isFound[i] = true;
			}
			i += 1;
		}
		omrtty_printf("\n");
	} while (seq <= numOfFiles);

	for (size_t i = 0; i < numOfNode; i++) {
		if (!isFound[i]) {
			rt = 1;
			omrtty_printf("*FAILED* Could not find xpath node \"%s\" in verbose output.\n", verboseGCs[i].node().attribute("xpathNodes").value());
		}
	}

done:
	omrmem_free_memory((void *)isFound);
	return rt;
}