Bootstrapping build process using proof-of-concept test runner.
This commit is contained in:
parent
b62273437c
commit
37ea67786d
7 changed files with 340 additions and 0 deletions
23
test/test-automation/.hgignore
Normal file
23
test/test-automation/.hgignore
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
syntax: glob
|
||||||
|
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
autom4te*
|
||||||
|
configure
|
||||||
|
config.h
|
||||||
|
config.cache
|
||||||
|
config.log
|
||||||
|
config.status
|
||||||
|
Makefile
|
||||||
|
runner
|
||||||
|
*.o
|
||||||
|
*.so
|
||||||
|
|
||||||
|
*.dSYM
|
||||||
|
|
||||||
|
# for vim
|
||||||
|
*.swp
|
||||||
|
|
||||||
|
# for Eclipse
|
||||||
|
.project
|
||||||
|
.cproject
|
52
test/test-automation/Makefile.in
Normal file
52
test/test-automation/Makefile.in
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
# @configure_input@
|
||||||
|
|
||||||
|
CFLAGS = -W -Wall -Wextra -g `sdl-config --cflags` -DSDL_NO_COMPAT
|
||||||
|
LDFLAGS = `sdl-config --libs`
|
||||||
|
|
||||||
|
CC = @CC@
|
||||||
|
#CFLAGS = @CFLAGS@
|
||||||
|
#LDFLAGS = @LIBS@
|
||||||
|
|
||||||
|
#@SET_MAKE@
|
||||||
|
SHELL = @SHELL@
|
||||||
|
srcdir = @srcdir@
|
||||||
|
|
||||||
|
SRC = runner.c
|
||||||
|
|
||||||
|
TEST_SRC = test.c
|
||||||
|
TEST_OBJ = test.o
|
||||||
|
|
||||||
|
ALL_TESTS = libtest.so
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
|
|
||||||
|
all: runner $(ALL_TESTS)
|
||||||
|
|
||||||
|
runner: $(SRC)
|
||||||
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+
|
||||||
|
|
||||||
|
tests: $(ALL_TESTS)
|
||||||
|
|
||||||
|
libtest.so: test.o
|
||||||
|
$(CC) -shared -wl,-soname,$@ -o $@ $+
|
||||||
|
|
||||||
|
test.o: $(TEST_SRC)
|
||||||
|
$(CC) -fPIC $(CFLAGS) -c $+ -o $@
|
||||||
|
|
||||||
|
Makefile: Makefile.in config.status
|
||||||
|
$(SHELL) /config.status $@
|
||||||
|
|
||||||
|
Makefile.in:
|
||||||
|
;
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f runner $(TESTS_ALL) *.o *.so
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
rm -f Makefile
|
||||||
|
rm -f config.{h,log,status}
|
||||||
|
rm -f configure configure.scan
|
||||||
|
rm -f autoscan.log
|
||||||
|
rm -Rf autom4te* *.dSYM
|
||||||
|
|
||||||
|
|
70
test/test-automation/config.h.in
Normal file
70
test/test-automation/config.h.in
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `fork' function. */
|
||||||
|
#undef HAVE_FORK
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
|
#undef HAVE_INTTYPES_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
|
#undef HAVE_MEMORY_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdint.h> header file. */
|
||||||
|
#undef HAVE_STDINT_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||||
|
#undef HAVE_STDLIB_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <strings.h> header file. */
|
||||||
|
#undef HAVE_STRINGS_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <string.h> header file. */
|
||||||
|
#undef HAVE_STRING_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||||
|
#undef HAVE_SYS_STAT_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||||
|
#undef HAVE_SYS_TYPES_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
|
#undef HAVE_UNISTD_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `vfork' function. */
|
||||||
|
#undef HAVE_VFORK
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <vfork.h> header file. */
|
||||||
|
#undef HAVE_VFORK_H
|
||||||
|
|
||||||
|
/* Define to 1 if `fork' works. */
|
||||||
|
#undef HAVE_WORKING_FORK
|
||||||
|
|
||||||
|
/* Define to 1 if `vfork' works. */
|
||||||
|
#undef HAVE_WORKING_VFORK
|
||||||
|
|
||||||
|
/* Define to the address where bug reports for this package should be sent. */
|
||||||
|
#undef PACKAGE_BUGREPORT
|
||||||
|
|
||||||
|
/* Define to the full name of this package. */
|
||||||
|
#undef PACKAGE_NAME
|
||||||
|
|
||||||
|
/* Define to the full name and version of this package. */
|
||||||
|
#undef PACKAGE_STRING
|
||||||
|
|
||||||
|
/* Define to the one symbol short name of this package. */
|
||||||
|
#undef PACKAGE_TARNAME
|
||||||
|
|
||||||
|
/* Define to the home page for this package. */
|
||||||
|
#undef PACKAGE_URL
|
||||||
|
|
||||||
|
/* Define to the version of this package. */
|
||||||
|
#undef PACKAGE_VERSION
|
||||||
|
|
||||||
|
/* Define to 1 if you have the ANSI C header files. */
|
||||||
|
#undef STDC_HEADERS
|
||||||
|
|
||||||
|
/* Define to `int' if <sys/types.h> does not define. */
|
||||||
|
#undef pid_t
|
||||||
|
|
||||||
|
/* Define as `fork' if `vfork' does not work. */
|
||||||
|
#undef vfork
|
23
test/test-automation/configure.ac
Normal file
23
test/test-automation/configure.ac
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# -*- Autoconf -*-
|
||||||
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
|
AC_PREREQ([2.65])
|
||||||
|
AC_INIT([runner], [0.01], [markus.kauppila@gmail.com])
|
||||||
|
AC_CONFIG_SRCDIR([runner.c])
|
||||||
|
AC_CONFIG_HEADERS([config.h])
|
||||||
|
|
||||||
|
# Checks for programs.
|
||||||
|
AC_PROG_CC
|
||||||
|
|
||||||
|
# Checks for libraries.
|
||||||
|
|
||||||
|
# Checks for header files.
|
||||||
|
AC_CHECK_HEADERS([stdlib.h unistd.h])
|
||||||
|
|
||||||
|
# Checks for typedefs, structures, and compiler characteristics.
|
||||||
|
|
||||||
|
# Checks for library functions.
|
||||||
|
AC_FUNC_FORK
|
||||||
|
|
||||||
|
AC_CONFIG_FILES([Makefile])
|
||||||
|
AC_OUTPUT
|
97
test/test-automation/runner.c
Normal file
97
test/test-automation/runner.c
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2011 Markus Kauppila <markus.kauppila@gmail.com>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "SDL/SDL_loadso.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
int pid = getpid();
|
||||||
|
int testsFailed = 0, testsPassed = 0;
|
||||||
|
|
||||||
|
char *libName = "libtest.so";
|
||||||
|
printf("%d: Loading .so containing tests\n", pid);
|
||||||
|
void *library = SDL_LoadObject(libName);
|
||||||
|
if(library == NULL) {
|
||||||
|
printf("Loading %s failed\n", libName);
|
||||||
|
printf("%s\n", SDL_GetError());
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%d: Asking for the test case names\n", pid);
|
||||||
|
char **(*suite)(void);
|
||||||
|
suite = (char **(*)(void)) SDL_LoadFunction(library, "suite");
|
||||||
|
if(suite == NULL) {
|
||||||
|
printf("%d: Retrieving test names failed, suite == NULL\n", pid);
|
||||||
|
printf("%s\n", SDL_GetError());
|
||||||
|
} else {
|
||||||
|
char **tests = suite();
|
||||||
|
|
||||||
|
char *testname = NULL;
|
||||||
|
int counter = 0;
|
||||||
|
for(; (testname = tests[counter]); ++counter) {
|
||||||
|
int childpid = fork();
|
||||||
|
if(childpid == 0) {
|
||||||
|
pid = getpid();
|
||||||
|
|
||||||
|
printf("%d: Loading test: %s\n", pid, testname);
|
||||||
|
|
||||||
|
void (*test)(void *arg);
|
||||||
|
|
||||||
|
test = (void (*)(void *)) SDL_LoadFunction(library, testname);
|
||||||
|
if(test == NULL) {
|
||||||
|
printf("%d: Loading test failed, tests == NULL\n", pid);
|
||||||
|
printf("%s\n", SDL_GetError());
|
||||||
|
} else {
|
||||||
|
test(0x0);
|
||||||
|
}
|
||||||
|
return 0; // exit the child if the test didn't exit
|
||||||
|
} else {
|
||||||
|
int stat_lock = -1;
|
||||||
|
int child = wait(&stat_lock);
|
||||||
|
|
||||||
|
if(WIFEXITED(stat_lock)) {
|
||||||
|
int rv = WEXITSTATUS(stat_lock);
|
||||||
|
printf("%d: %d exited normally with value %d\n", pid, child, rv);
|
||||||
|
|
||||||
|
testsPassed++;
|
||||||
|
} else if(WIFSIGNALED(stat_lock)) {
|
||||||
|
int signal = WTERMSIG(stat_lock);
|
||||||
|
printf("%d: %d was killed by signal nro %d\n", pid, child, signal);
|
||||||
|
|
||||||
|
testsFailed++;
|
||||||
|
} else if(WIFSTOPPED(stat_lock)) {
|
||||||
|
//int signal = WSTOPSIG(stat_lock);
|
||||||
|
//printf("%d: %d was stopped by signal nro %d\n", pid, child, signal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%d: all tests executed\n", pid);
|
||||||
|
printf("%d: %d tests passed\n", pid, testsPassed);
|
||||||
|
printf("%d: %d tests failed\n", pid, testsFailed);
|
||||||
|
|
||||||
|
SDL_UnloadObject(library);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
45
test/test-automation/test.c
Normal file
45
test/test-automation/test.c
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2011 Markus Kauppila <markus.kauppila@gmail.com>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TEST_C
|
||||||
|
#define _TEST_C
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
char *names[] = {"hello", "hello2", "hello3"};
|
||||||
|
|
||||||
|
char **suite() {
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
|
void hello(void *arg){
|
||||||
|
printf("hello\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void hello2(void *arg) {
|
||||||
|
char *msg = "eello";
|
||||||
|
msg[0] = 'H';
|
||||||
|
}
|
||||||
|
|
||||||
|
void hello3(void *arg) {
|
||||||
|
printf("hello\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
30
test/test-automation/test.h
Normal file
30
test/test-automation/test.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2011 Markus Kauppila <markus.kauppila@gmail.com>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TEST_H
|
||||||
|
#define _TEST_H
|
||||||
|
|
||||||
|
char **suite();
|
||||||
|
|
||||||
|
void hello(void *arg);
|
||||||
|
void hello2(void *arg);
|
||||||
|
void hello3(void *arg);
|
||||||
|
|
||||||
|
#endif
|
Loading…
Add table
Add a link
Reference in a new issue