| 853 | } |
| 854 | |
| 855 | static int |
| 856 | xstcTestGroup(xmlNodePtr cur, const char *base) { |
| 857 | xmlChar *href = NULL; |
| 858 | xmlChar *path = NULL; |
| 859 | xmlChar *validity = NULL; |
| 860 | xmlSchemaPtr schemas = NULL; |
| 861 | xmlSchemaParserCtxtPtr ctxt; |
| 862 | xmlNodePtr instance; |
| 863 | int ret = 0, mem; |
| 864 | |
| 865 | xmlResetLastError(); |
| 866 | testErrorsSize = 0; testErrors[0] = 0; |
| 867 | mem = xmlMemUsed(); |
| 868 | href = getString(cur, |
| 869 | "string(ts:schemaTest/ts:schemaDocument/@xlink:href)"); |
| 870 | if ((href == NULL) || (href[0] == 0)) { |
| 871 | test_log("testGroup line %ld misses href for schemaDocument\n", |
| 872 | xmlGetLineNo(cur)); |
| 873 | ret = -1; |
| 874 | goto done; |
| 875 | } |
| 876 | path = xmlBuildURI(href, BAD_CAST base); |
| 877 | if (path == NULL) { |
| 878 | test_log("Failed to build path to schemas testGroup line %ld : %s\n", |
| 879 | xmlGetLineNo(cur), href); |
| 880 | ret = -1; |
| 881 | goto done; |
| 882 | } |
| 883 | if (checkTestFile((const char *) path) <= 0) { |
| 884 | test_log("schemas for testGroup line %ld is missing: %s\n", |
| 885 | xmlGetLineNo(cur), path); |
| 886 | ret = -1; |
| 887 | goto done; |
| 888 | } |
| 889 | validity = getString(cur, |
| 890 | "string(ts:schemaTest/ts:expected/@validity)"); |
| 891 | if (validity == NULL) { |
| 892 | test_log("testGroup line %ld misses expected validity\n", |
| 893 | xmlGetLineNo(cur)); |
| 894 | ret = -1; |
| 895 | goto done; |
| 896 | } |
| 897 | nb_tests++; |
| 898 | if (xmlStrEqual(validity, BAD_CAST "valid")) { |
| 899 | nb_schematas++; |
| 900 | ctxt = xmlSchemaNewParserCtxt((const char *) path); |
| 901 | xmlSchemaSetParserErrors(ctxt, testErrorHandler, testErrorHandler, |
| 902 | ctxt); |
| 903 | schemas = xmlSchemaParse(ctxt); |
| 904 | xmlSchemaFreeParserCtxt(ctxt); |
| 905 | if (schemas == NULL) { |
| 906 | test_log("valid schemas %s failed to parse\n", |
| 907 | path); |
| 908 | ret = 1; |
| 909 | nb_errors++; |
| 910 | } |
| 911 | if ((ret == 0) && (strstr(testErrors, "nimplemented") != NULL)) { |
| 912 | test_log("valid schemas %s hit an unimplemented block\n", |
no test coverage detected