| @@ -62,14 +62,14 @@ static bool diff_files(const char *expected_path, const char *actual_path) | |||||
| bool same = false; | bool same = false; | ||||
| FILE *expected = NULL, *actual = NULL; | FILE *expected = NULL, *actual = NULL; | ||||
| if (!(expected = fopen(expected_path, "rb"))) { | |||||
| FAIL_TEST("missing reference file: %s", expected_path) | |||||
| goto cleanup; | |||||
| } | |||||
| if (!(actual = fopen(actual_path, "rb"))) { | if (!(actual = fopen(actual_path, "rb"))) { | ||||
| FAIL_TEST("missing output file: %s", actual_path) | FAIL_TEST("missing output file: %s", actual_path) | ||||
| goto cleanup; | goto cleanup; | ||||
| } | } | ||||
| if (!(expected = fopen(expected_path, "rb"))) { | |||||
| FAIL_TEST("missing reference file: %s", expected_path) | |||||
| goto cleanup; | |||||
| } | |||||
| size_t len = 0; | size_t len = 0; | ||||
| int e, a; | int e, a; | ||||
| @@ -103,6 +103,14 @@ static bool diff_files(const char *expected_path, const char *actual_path) | |||||
| } | } | ||||
| /* | /* | ||||
| Return whether the given character is valid within a filename. | |||||
| */ | |||||
| static bool is_valid_filename_char(char c) { | |||||
| return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || | |||||
| (c >= '0' && c <= '9') || c == '.' || c == '_' || c == '-'; | |||||
| } | |||||
| /* | |||||
| Run a single ASM->ROM test, converting the given source file to a temporary | Run a single ASM->ROM test, converting the given source file to a temporary | ||||
| output file, compared against the reference file. | output file, compared against the reference file. | ||||
| */ | */ | ||||
| @@ -169,8 +177,8 @@ static bool test_asm() | |||||
| return false; | return false; | ||||
| } | } | ||||
| char *line = NULL, *split; | |||||
| size_t cap = 0, lineno = 0; | |||||
| char *line = NULL, *split, c; | |||||
| size_t cap = 0, lineno = 0, i; | |||||
| ssize_t len; | ssize_t len; | ||||
| while ((len = getline(&line, &cap, fp)) > 0) { | while ((len = getline(&line, &cap, fp)) > 0) { | ||||
| @@ -179,7 +187,14 @@ static bool test_asm() | |||||
| if (!len) | if (!len) | ||||
| continue; | continue; | ||||
| // TODO: validate chars | |||||
| i = 0; | |||||
| while ((c = line[i++])) { | |||||
| if (!is_valid_filename_char(c) && c != ' ') { | |||||
| READY_STDOUT() | |||||
| ERROR("bad character in manifest file on line %zu", lineno) | |||||
| return false; | |||||
| } | |||||
| } | |||||
| split = strchr(line, ' '); | split = strchr(line, ' '); | ||||
| if (!split || strchr(split + 1, ' ')) { | if (!split || strchr(split + 1, ' ')) { | ||||