1 #include <pg_query.h> 2 3 #include <stdio.h> 4 #include <stdlib.h> 5 #include <string.h> 6 #include <stdbool.h> 7 #include <pthread.h> 8 9 #include "parse_tests.c" 10 11 #define THREAD_COUNT 500 12 13 void* test_runner(void*); 14 15 int main() { 16 size_t i; 17 int ret; 18 pthread_t threads[THREAD_COUNT]; 19 20 for (i = 0; i < THREAD_COUNT; i += 1) { 21 ret = pthread_create(&threads[i], NULL, test_runner, NULL); 22 if (ret) { 23 perror("ERROR creating pthread"); 24 return 1; 25 } 26 } 27 28 for (i = 0; i < THREAD_COUNT; i += 1) { 29 pthread_join(threads[i], NULL); 30 } 31 32 printf("\n"); 33 34 return 0; 35 } 36 37 void* test_runner(void* ptr) { 38 size_t i; 39 40 for (i = 0; i < testsLength; i += 2) { 41 PgQueryParseResult result = pg_query_parse(tests[i]); 42 43 if (result.error) { 44 printf("%s\n", result.error->message); 45 } else if (strcmp(result.parse_tree, tests[i + 1]) == 0) { 46 printf("."); 47 } else { 48 printf("INVALID result for \"%s\"\nexpected: %s\nactual: %s\n", tests[i], tests[i + 1], result.parse_tree); 49 } 50 51 pg_query_free_parse_result(result); 52 } 53 54 return NULL; 55 } 56