mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	tests: Add a help message for the test runner
In case we forget the name of the test case or typo it, the test runner will now list the test cases in the test binary.
This commit is contained in:
		
							parent
							
								
									adcb2d73b3
								
							
						
					
					
						commit
						13d5271b47
					
				
					 1 changed files with 22 additions and 1 deletions
				
			
		| 
						 | 
					@ -89,6 +89,24 @@ find_test(const char *name)
 | 
				
			||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					usage(const char *name, int status)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						const struct test *t;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						fprintf(stderr, "Usage: %s [TEST]\n\n"
 | 
				
			||||||
 | 
							"With no arguments, run all test.  Specify test case to run\n"
 | 
				
			||||||
 | 
							"only that test without forking.  Available tests:\n\n",
 | 
				
			||||||
 | 
							name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for (t = &__start_test_section; t < &__stop_test_section; t++)
 | 
				
			||||||
 | 
							fprintf(stderr, "  %s\n", t->name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						fprintf(stderr, "\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						exit(status);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
run_test(const struct test *t)
 | 
					run_test(const struct test *t)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -119,11 +137,14 @@ int main(int argc, char *argv[])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	leak_check_enabled = !getenv("NO_ASSERT_LEAK_CHECK");
 | 
						leak_check_enabled = !getenv("NO_ASSERT_LEAK_CHECK");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (argc == 2 && strcmp(argv[1], "--help") == 0)
 | 
				
			||||||
 | 
							usage(argv[0], EXIT_SUCCESS);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (argc == 2) {
 | 
						if (argc == 2) {
 | 
				
			||||||
		t = find_test(argv[1]);
 | 
							t = find_test(argv[1]);
 | 
				
			||||||
		if (t == NULL) {
 | 
							if (t == NULL) {
 | 
				
			||||||
			fprintf(stderr, "unknown test: \"%s\"\n", argv[1]);
 | 
								fprintf(stderr, "unknown test: \"%s\"\n", argv[1]);
 | 
				
			||||||
			exit(EXIT_FAILURE);
 | 
								usage(argv[0], EXIT_FAILURE);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		run_test(t);
 | 
							run_test(t);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue