This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 1a4cfc00663ccc76f058a87cc00c031ec57dd982 (commit) from f7e6f933c737b7904e59d85438747f27785a89ac (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/1a4cfc00663ccc76f058a87cc00c031ec57dd...
commit 1a4cfc00663ccc76f058a87cc00c031ec57dd982 Author: Cyril Hrubis metan@ucw.cz Date: Fri Nov 2 16:33:03 2012 +0100
tests: framework: Make output silent by default.
- shuffle some code to cleanup the sources - add verbose switch and set it off by default - add global runtest script to execute all testsuites
diff --git a/tests/framework/Makefile b/tests/framework/Makefile index f3e22a1..a688952 100644 --- a/tests/framework/Makefile +++ b/tests/framework/Makefile @@ -17,7 +17,7 @@ ALL+=libtst_preload.so libtst.a libtst_preload.so: tst_preload.o tst_alloc_barriers.o tst_preload_FILE.o gcc -Wl,-soname -Wl,tst_preload.so --shared -ldl -fPIC $^ -o $@
-libtst.a: tst_test.o tst_job.o tst_msg.o tst_log.o tst_main.o tst_timespec.o +libtst.a: tst_suite.o tst_job.o tst_msg.o tst_log.o tst_main.o tst_timespec.o ar rcs $@ $^
CLEAN+=libtst_preload.so libtst.a log.html log.json diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c index ce39d41..e60736b 100644 --- a/tests/framework/tst_job.c +++ b/tests/framework/tst_job.c @@ -33,7 +33,6 @@ #include <stdarg.h> #include <math.h>
-#include "tst_preload.h" #include "tst_test.h" #include "tst_job.h" #include "tst_timespec.h" @@ -48,100 +47,6 @@ static int in_child(void) return my_job != NULL; }
-static void start_test(struct tst_job *job) -{ - (void)job; -// fprintf(stderr, "Starting test e[1;37m%se[0mn", job->test->name); -} - -void tst_diff_timespec(int *sec, int *nsec, struct timespec *start, - struct timespec *stop) -{ - if (stop->tv_nsec < start->tv_nsec) { - *sec = stop->tv_sec - start->tv_sec - 1; - *nsec = stop->tv_nsec + 1000000000 - start->tv_nsec; - } else { - *sec = stop->tv_sec - start->tv_sec; - *nsec = stop->tv_nsec - start->tv_nsec; - } -} - -#define NAME_PADD 35 - -static void stop_test(struct tst_job *job) -{ - const char *name = job->test->name; - int sec, nsec; - const char *result = ""; - - tst_diff_timespec(&sec, &nsec, &job->start_time, &job->stop_time); - - switch (job->result) { - case TST_SUCCESS: - result = "[ e[1;32mSUCCESSe[0m ]"; - break; - case TST_SKIPPED: - result = "[ e[1;30mSKIPPEDe[0m ]"; - break; - case TST_UNTESTED: - result = "[ e[1;34mUNTESTEDe[0m ]"; - break; - case TST_INTERR: - result = "[ e[1;31mINTERNAL ERRORe[0m ]"; - break; - case TST_SIGSEGV: - result = "[ e[1;31mSEGFAULTe[0m ]"; - break; - case TST_TIMEOUT: - result = "[ e[1;35mTIMEOUTe[0m ]"; - break; - case TST_ABORTED: - result = "[ e[1;31mABORTEDe[0m ]"; - break; - case TST_FPE: - result = "[ e[1;31mFP EXCEPTIONe[0m ]"; - break; - case TST_MEMLEAK: - result = "[ e[1;33mMEMLEAKe[0m ]"; - break; - case TST_FAILED: - result = "[ e[1;31mFAILUREe[0m ]"; - break; - case TST_MAX: - break; - } - - fprintf(stderr, "e[1;37m%se[0m", name); - - int i; - - for (i = strlen(name); i < NAME_PADD; i++) - fprintf(stderr, " "); - - fprintf(stderr, " finished (Time %3i.%03is) %sn", - sec, nsec/1000000, result); - - if (job->bench_iter) { - for (i = 0; i < NAME_PADD; i++) - fprintf(stderr, " "); - - fprintf(stderr, " bench CPU time %i.%06is +/- %i.%06isn", - (int)job->bench_mean.tv_sec, - (int)job->bench_mean.tv_nsec/1000, - (int)job->bench_var.tv_sec, - (int)job->bench_var.tv_nsec/1000); - } - - if (job->result == TST_MEMLEAK) - tst_malloc_print(&job->malloc_stats); - - /* Now print test message store */ - tst_msg_print(&job->store); - - fprintf(stderr, "------------------------------------------------------" - "------------------------- n"); -} - /* * Removes recursively temporary directory. */ @@ -438,9 +343,6 @@ void tst_job_run(struct tst_job *job) /* Prepare the test message store */ tst_msg_init(&job->store);
- /* marks test as started */ - start_test(job); - /* copy benchmark interation */ job->bench_iter = job->test->bench_iter;
@@ -667,8 +569,6 @@ void tst_job_collect(struct tst_job *job) /* Write down stop time */ clock_gettime(CLOCK_MONOTONIC, &job->stop_time); - - stop_test(job); }
void tst_job_wait(struct tst_job *job) diff --git a/tests/framework/tst_job.h b/tests/framework/tst_job.h index 76984e5..171c0f0 100644 --- a/tests/framework/tst_job.h +++ b/tests/framework/tst_job.h @@ -90,7 +90,4 @@ void tst_job_run(struct tst_job *job); */ void tst_job_wait(struct tst_job *job);
-void tst_diff_timespec(int *sec, int *nsec, struct timespec *start, - struct timespec *stop); - #endif /* TST_JOB_H */ diff --git a/tests/framework/tst_log.c b/tests/framework/tst_log.c index a70f8c0..9daec17 100644 --- a/tests/framework/tst_log.c +++ b/tests/framework/tst_log.c @@ -27,6 +27,7 @@ #include "tst_job.h" #include "tst_msg.h" #include "tst_preload.h" +#include "tst_timespec.h" #include "tst_log.h"
static const char *ret_to_bg_color(enum tst_ret ret) @@ -249,7 +250,7 @@ static int append_html(struct tst_job *job, FILE *f) static int hack_counter = 0; const char *bgcol;
- tst_diff_timespec(&sec, &nsec, &job->start_time, &job->stop_time); + timespec_diff(&sec, &nsec, &job->start_time, &job->stop_time);
if (hack_counter) bgcol = "#ccccee"; @@ -375,7 +376,7 @@ static int append_json(struct tst_job *job, FILE *f) /* Time statistics */ int sec, nsec;
- tst_diff_timespec(&sec, &nsec, &job->start_time, &job->stop_time); + timespec_diff(&sec, &nsec, &job->start_time, &job->stop_time); fprintf(f, "ttt"CPU Time": %i.%09i,n", (int)job->cpu_time.tv_sec, (int)job->cpu_time.tv_nsec); diff --git a/tests/framework/tst_main.c b/tests/framework/tst_main.c index 28020a0..d1c6474 100644 --- a/tests/framework/tst_main.c +++ b/tests/framework/tst_main.c @@ -28,12 +28,16 @@
extern const struct tst_suite tst_suite;
+/* defined in tst_suite.c */ +extern int tst_suite_verbose; + void print_help(void) { fprintf(stderr, "Test suite '%s' Usage:nn", tst_suite.suite_name); fprintf(stderr, "-h prints this helpn"); fprintf(stderr, "-l list all testsn"); fprintf(stderr, "-t name runs single test by namen"); + fprintf(stderr, "-v turns on verbose moden"); fprintf(stderr, "without any option, all tests are executedn"); }
@@ -41,7 +45,7 @@ int main(int argc, char *argv[]) { int opt;
- while ((opt = getopt(argc, argv, "hlt:")) != -1) { + while ((opt = getopt(argc, argv, "hlt:v")) != -1) { switch (opt) { case 'l': tst_list_suite(&tst_suite); @@ -55,6 +59,9 @@ int main(int argc, char *argv[]) print_help(); return 0; break; + case 'v': + tst_suite_verbose = 1; + break; default: print_help(); return 1; diff --git a/tests/framework/tst_msg.c b/tests/framework/tst_msg.c index 852fb81..8deafd1 100644 --- a/tests/framework/tst_msg.c +++ b/tests/framework/tst_msg.c @@ -85,7 +85,7 @@ static char type_to_char(enum tst_report_type type) } }
-void tst_msg_print(struct tst_msg_store *self) +void tst_msg_print(const struct tst_msg_store *self) { struct tst_msg *msg;
diff --git a/tests/framework/tst_msg.h b/tests/framework/tst_msg.h index a6a290a..f144851 100644 --- a/tests/framework/tst_msg.h +++ b/tests/framework/tst_msg.h @@ -62,6 +62,6 @@ int tst_msg_append(struct tst_msg_store *self, int type, const char *msg); /* * Prints messages in the store. */ -void tst_msg_print(struct tst_msg_store *self); +void tst_msg_print(const struct tst_msg_store *self);
#endif /* TST_MSG_H */ diff --git a/tests/framework/tst_preload.c b/tests/framework/tst_preload.c index 7241926..aec364f 100644 --- a/tests/framework/tst_preload.c +++ b/tests/framework/tst_preload.c @@ -146,7 +146,7 @@ void free(void *ptr) real_free(ptr); }
-void tst_malloc_print(struct malloc_stats *stats) +void tst_malloc_print(const struct malloc_stats *stats) { fprintf(stderr, "Total size %zu chunks %u, lost size %zu chunks %un", stats->total_size, stats->total_chunks, diff --git a/tests/framework/tst_preload.h b/tests/framework/tst_preload.h index d103e8c..0c44d3d 100644 --- a/tests/framework/tst_preload.h +++ b/tests/framework/tst_preload.h @@ -65,6 +65,6 @@ void tst_malloc_check_report(struct malloc_stats *stats); /* * Prints malloc statistics. */ -void tst_malloc_print(struct malloc_stats *stats); +void tst_malloc_print(const struct malloc_stats *stats);
#endif /* TST_PRELOAD_H */ diff --git a/tests/framework/tst_suite.c b/tests/framework/tst_suite.c new file mode 100644 index 0000000..1c0440b --- /dev/null +++ b/tests/framework/tst_suite.c @@ -0,0 +1,195 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <errno.h> +#include <string.h> +#include <stdarg.h> + +#include "tst_log.h" +#include "tst_job.h" +#include "tst_test.h" +#include "tst_preload.h" +#include "tst_timespec.h" + +#define NAME_PADD 35 + +int tst_suite_verbose = 0; + +static void test_job_report(const struct tst_job *job) +{ + const char *name = job->test->name; + int sec, nsec; + const char *result = ""; + + if ((job->result == TST_SUCCESS || job->result == TST_SKIPPED) + && !tst_suite_verbose) + return; + + timespec_diff(&sec, &nsec, &job->start_time, &job->stop_time); + + switch (job->result) { + case TST_SUCCESS: + result = "[ e[1;32mSUCCESSe[0m ]"; + break; + case TST_SKIPPED: + result = "[ e[1;30mSKIPPEDe[0m ]"; + break; + case TST_UNTESTED: + result = "[ e[1;34mUNTESTEDe[0m ]"; + break; + case TST_INTERR: + result = "[ e[1;31mINTERNAL ERRORe[0m ]"; + break; + case TST_SIGSEGV: + result = "[ e[1;31mSEGFAULTe[0m ]"; + break; + case TST_TIMEOUT: + result = "[ e[1;35mTIMEOUTe[0m ]"; + break; + case TST_ABORTED: + result = "[ e[1;31mABORTEDe[0m ]"; + break; + case TST_FPE: + result = "[ e[1;31mFP EXCEPTIONe[0m ]"; + break; + case TST_MEMLEAK: + result = "[ e[1;33mMEMLEAKe[0m ]"; + break; + case TST_FAILED: + result = "[ e[1;31mFAILUREe[0m ]"; + break; + case TST_MAX: + break; + } + + fprintf(stderr, "e[1;37m%se[0m", name); + + int i; + + for (i = strlen(name); i < NAME_PADD; i++) + fprintf(stderr, " "); + + fprintf(stderr, " finished (Time %3i.%03is) %sn", + sec, nsec/1000000, result); + + if (job->bench_iter) { + for (i = 0; i < NAME_PADD; i++) + fprintf(stderr, " "); + + fprintf(stderr, " bench CPU time %i.%06is +/- %i.%06isn", + (int)job->bench_mean.tv_sec, + (int)job->bench_mean.tv_nsec/1000, + (int)job->bench_var.tv_sec, + (int)job->bench_var.tv_nsec/1000); + } + + if (job->result == TST_MEMLEAK) + tst_malloc_print(&job->malloc_stats); + + /* Now print test message store */ + tst_msg_print(&job->store); + + fprintf(stderr, "------------------------------------------------------" + "------------------------- n"); +} + +static int run_test(const struct tst_test *test, FILE *html, FILE *json) +{ + struct tst_job job; + + job.test = test; + + /* + * Flush the file before forking, otherwise + * there would be a copy of its buffers in both + * child and parent and the lines in the resulting + * file would be repeated several times. + */ + fflush(html); + fflush(json); + + tst_job_run(&job); + tst_job_wait(&job); + + /* report result into stdout */ + test_job_report(&job); + + tst_log_append(&job, html, TST_LOG_HTML); + tst_log_append(&job, json, TST_LOG_JSON); + + /* Free the test message store */ + tst_msg_clear(&job.store); + + return job.result; +} + +void tst_run_suite(const struct tst_suite *suite, const char *tst_name) +{ + unsigned int i; + unsigned int counters[TST_MAX] = {}; + unsigned int counter = 0; + int ret; + + fprintf(stderr, "Running e[1;37m%se[0mnn", suite->suite_name); + + //TODO: + FILE *html = tst_log_open(suite, "log.html", TST_LOG_HTML); + FILE *json = tst_log_open(suite, "log.json", TST_LOG_JSON); + + for (i = 0; suite->tests[i].name != NULL; i++) { + if (tst_name == NULL || !strcmp(tst_name, suite->tests[i].name)) { + ret = run_test(&suite->tests[i], html, json); + counters[ret]++; + + if (ret != TST_SKIPPED) + counter++; + } + } + + tst_log_close(html, TST_LOG_HTML); + tst_log_close(json, TST_LOG_JSON); + + float percents; + + if (counter == 0) + percents = 100; + else + percents = 100.00 * counters[0] / counter; + + fprintf(stderr, "nSummary: succedded %u out of " + "%u %.2f%% (skipped %u)n", + counters[0], counter, percents, + counters[TST_SKIPPED]); +} + +void tst_list_suite(const struct tst_suite *suite) +{ + int i; + + fprintf(stderr, "Testsuite: e[1;37m%se[0mnn", suite->suite_name); + + for (i = 0; suite->tests[i].name != NULL; i++) + fprintf(stderr, "Test: e[1;37m%se[0mn", suite->tests[i].name); +} diff --git a/tests/framework/tst_test.c b/tests/framework/tst_test.c deleted file mode 100644 index 62666da..0000000 --- a/tests/framework/tst_test.c +++ /dev/null @@ -1,108 +0,0 @@ -/***************************************************************************** - * This file is part of gfxprim library. * - * * - * Gfxprim is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * Gfxprim is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with gfxprim; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02110-1301 USA * - * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * - * * - *****************************************************************************/ - -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> -#include <string.h> -#include <stdarg.h> - -#include "tst_log.h" -#include "tst_job.h" -#include "tst_test.h" - -static int run_test(const struct tst_test *test, FILE *html, FILE *json) -{ - struct tst_job job; - - job.test = test; - - /* - * Flush the file before forking, otherwise - * there would be a copy of its buffers in both - * child and parent and the lines in the resulting - * file would be repeated several times. - */ - fflush(html); - fflush(json); - - tst_job_run(&job); - tst_job_wait(&job); - - tst_log_append(&job, html, TST_LOG_HTML); - tst_log_append(&job, json, TST_LOG_JSON); - - /* Free the test message store */ - tst_msg_clear(&job.store); - - return job.result; -} - -void tst_run_suite(const struct tst_suite *suite, const char *tst_name) -{ - unsigned int i; - unsigned int counters[TST_MAX] = {}; - unsigned int counter = 0; - int ret; - - fprintf(stderr, "Running e[1;37m%se[0mnn", suite->suite_name); - - //TODO: - FILE *html = tst_log_open(suite, "log.html", TST_LOG_HTML); - FILE *json = tst_log_open(suite, "log.json", TST_LOG_JSON); - - for (i = 0; suite->tests[i].name != NULL; i++) { - if (tst_name == NULL || !strcmp(tst_name, suite->tests[i].name)) { - ret = run_test(&suite->tests[i], html, json); - counters[ret]++; - - if (ret != TST_SKIPPED) - counter++; - } - } - - tst_log_close(html, TST_LOG_HTML); - tst_log_close(json, TST_LOG_JSON); - - float percents; - - if (counter == 0) - percents = 100; - else - percents = 100.00 * counters[0] / counter; - - fprintf(stderr, "nSummary: succedded %u out of " - "%u %.2f%% (skipped %u)n", - counters[0], counter, percents, - counters[TST_SKIPPED]); -} - -void tst_list_suite(const struct tst_suite *suite) -{ - int i; - - fprintf(stderr, "Testsuite: e[1;37m%se[0mnn", suite->suite_name); - - for (i = 0; suite->tests[i].name != NULL; i++) - fprintf(stderr, "Test: e[1;37m%se[0mn", suite->tests[i].name); -} diff --git a/tests/framework/tst_test.h b/tests/framework/tst_test.h index 186d497..937f1cf 100644 --- a/tests/framework/tst_test.h +++ b/tests/framework/tst_test.h @@ -75,6 +75,7 @@ struct tst_test {
struct tst_suite { const char *suite_name; + int verbose:1; struct tst_test tests[]; };
diff --git a/tests/framework/tst_timespec.c b/tests/framework/tst_timespec.c index d388502..233095c 100644 --- a/tests/framework/tst_timespec.c +++ b/tests/framework/tst_timespec.c @@ -24,6 +24,19 @@
#define NSEC_IN_SEC 1000000000
+void timespec_diff(int *sec, int *nsec, + const struct timespec *start, + const struct timespec *stop) +{ + if (stop->tv_nsec < start->tv_nsec) { + *sec = stop->tv_sec - start->tv_sec - 1; + *nsec = stop->tv_nsec + 1000000000 - start->tv_nsec; + } else { + *sec = stop->tv_sec - start->tv_sec; + *nsec = stop->tv_nsec - start->tv_nsec; + } +} + double timespec_to_double(const struct timespec *t) { double res; diff --git a/tests/framework/tst_timespec.h b/tests/framework/tst_timespec.h index 25d010c..27ab5cb 100644 --- a/tests/framework/tst_timespec.h +++ b/tests/framework/tst_timespec.h @@ -31,6 +31,10 @@
#include <time.h>
+void timespec_diff(int *sec, int *nsec, + const struct timespec *start, + const struct timespec *stop); + double timespec_to_double(const struct timespec *t);
void double_to_timespec(const double time, struct timespec *res); diff --git a/tests/runtests.sh b/tests/runtests.sh new file mode 100755 index 0000000..f15668b --- /dev/null +++ b/tests/runtests.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +DIRS="core loaders gfx" + +for i in $DIRS; do + cd $i + ./runtest.sh $@ + cd .. +done
-----------------------------------------------------------------------
Summary of changes: tests/framework/Makefile | 2 +- tests/framework/tst_job.c | 100 -------------------- tests/framework/tst_job.h | 3 - tests/framework/tst_log.c | 5 +- tests/framework/tst_main.c | 9 ++- tests/framework/tst_msg.c | 2 +- tests/framework/tst_msg.h | 2 +- tests/framework/tst_preload.c | 2 +- tests/framework/tst_preload.h | 2 +- tests/framework/tst_suite.c | 195 ++++++++++++++++++++++++++++++++++++++++ tests/framework/tst_test.c | 108 ---------------------- tests/framework/tst_test.h | 1 + tests/framework/tst_timespec.c | 13 +++ tests/framework/tst_timespec.h | 4 + tests/runtests.sh | 9 ++ 15 files changed, 238 insertions(+), 219 deletions(-) create mode 100644 tests/framework/tst_suite.c delete mode 100644 tests/framework/tst_test.c create mode 100755 tests/runtests.sh
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.