diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2009-08-22 19:16:55 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2009-08-23 17:31:51 -0700 |
commit | bf5dbf79ebfba0de4c63263de8efdab73db4bbad (patch) | |
tree | 1828fef7f815289e67cb71efe28fc9b5c1e95fb3 /tests | |
parent | 491a658b97bf949600726b620349a302aafa5fe3 (diff) |
Compile tests using both DOS and Unix line endings.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/asmparsertest/asmparsertest.c | 130 |
1 files changed, 105 insertions, 25 deletions
diff --git a/tests/asmparsertest/asmparsertest.c b/tests/asmparsertest/asmparsertest.c index c50c59ae4..55bd65450 100644 --- a/tests/asmparsertest/asmparsertest.c +++ b/tests/asmparsertest/asmparsertest.c @@ -41,15 +41,78 @@ int automatic = FALSE; +char * +unix_line_endings(const char *input, size_t length) +{ + char *output = malloc(length + 1); + unsigned i; + unsigned j = 0; + + for (i = 0; i < length; i++) { + if ((input[i] == 0x0D) && (input[i + 1] == 0x0A)) { + i++; + output[j] = 0x0A; + } else { + output[j] = input[i]; + } + + j++; + } + + output[j] = '\0'; + return output; +} + + +char * +dos_line_endings(const char *input, size_t length) +{ + char *output; + unsigned i; + unsigned j = 0; + size_t new_length = length; + + + for (i = 0; i < length; i++) { + if (input[i] == 0x0A) { + new_length++; + } + } + + output = malloc(new_length + 1); + for (i = 0; i < length; i++) { + if ((input[i] == 0x0D) && (input[i + 1] == 0x0A)) { + i++; + output[j + 0] = 0x0D; + output[j + 1] = 0x0A; + j += 2; + } else if (input[i] == 0x0A) { + output[j + 0] = 0x0D; + output[j + 1] = 0x0A; + j += 2; + } else { + output[j] = input[i]; + j++; + } + } + + output[j] = '\0'; + return output; +} + + void compile(const char *filename, GLenum target, int use_ARB) { GLenum err; - GLuint prognum; + GLuint prognum[2]; char *buf; char *ptr; unsigned sz; int expected_fail; + char *converted_buffers[2]; + size_t buffer_sizes[2]; + unsigned i; if (!automatic) { @@ -95,42 +158,59 @@ compile(const char *filename, GLenum target, int use_ARB) } - /* The use_ARB flag is used instead of the target because - * GL_VERTEX_PROGRAM_ARB and GL_VERTEX_PROGRAM_NV have the same value. - */ + converted_buffers[0] = unix_line_endings(buf, sz); + buffer_sizes[0] = strlen(converted_buffers[0]); + converted_buffers[1] = dos_line_endings(buf, sz); + buffer_sizes[1] = strlen(converted_buffers[1]); + if (use_ARB) { glEnable(target); - - glGenProgramsARB(1, &prognum); - glBindProgramARB(target, prognum); - glProgramStringARB(target, GL_PROGRAM_FORMAT_ASCII_ARB, sz, - (const GLubyte *) buf); + glGenProgramsARB(2, prognum); } else { - glGenProgramsNV(1, &prognum); - glBindProgramNV(target, prognum); - glLoadProgramNV(target, prognum, sz, (const GLubyte *) buf); + glGenProgramsNV(2, prognum); } - err = glGetError(); - if (err != GL_NO_ERROR) { - GLint errorpos; + for (i = 0; i < 2; i++) { + /* The use_ARB flag is used instead of the target because + * GL_VERTEX_PROGRAM_ARB and GL_VERTEX_PROGRAM_NV have the same + * value. + */ + if (use_ARB) { + glBindProgramARB(target, prognum[i]); + glProgramStringARB(target, GL_PROGRAM_FORMAT_ASCII_ARB, + buffer_sizes[i], + (const GLubyte *) converted_buffers[i]); + } else { + glBindProgramNV(target, prognum[i]); + glLoadProgramNV(target, prognum[i], + buffer_sizes[i], + (const GLubyte *) converted_buffers[i]); + } - glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); - if (!automatic) { - printf("glGetError = 0x%04x\n", err); - printf("errorpos: %d\n", errorpos); - printf("%s\n", - (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + err = glGetError(); + if (err != GL_NO_ERROR) { + GLint errorpos; + + glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); + if (!automatic) { + printf("glGetError = 0x%04x\n", err); + printf("errorpos: %d\n", errorpos); + printf("%s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + } } - } + if ((err == GL_NO_ERROR) != (expected_fail == FALSE)) { + piglit_report_result(PIGLIT_FAILURE); + } + } free(buf); + free(converted_buffers[0]); + free(converted_buffers[1]); - if ((err == GL_NO_ERROR) != (expected_fail == FALSE)) { - piglit_report_result(PIGLIT_FAILURE); - } } |