ucw.cz
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
List overview
Download
Gfxprim
October 2012
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
gfxprim@ucw.cz
1 participants
24 discussions
Start a n
N
ew thread
[repo.or.cz] gfxprim.git branch master updated: 727d637ad22f615be1b18741e3efd9a829dfed2b
by metan
13 Oct '12
13 Oct '12
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 727d637ad22f615be1b18741e3efd9a829dfed2b (commit) from c86751325f6076b6ea840a1a689b99e30f6c35ca (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/727d637ad22f615be1b18741e3efd9a829df…
commit 727d637ad22f615be1b18741e3efd9a829dfed2b Author: Cyril Hrubis <metan(a)ucw.cz> Date: Sat Oct 13 17:12:42 2012 +0200 tests: framework: A little cleanup. diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c index c02fa9f..ad71ba8 100644 --- a/tests/framework/tst_job.c +++ b/tests/framework/tst_job.c @@ -60,7 +60,7 @@ void tst_diff_timespec(int *sec, int *nsec, struct timespec *start, } } -#define NAME_PADD 23 +#define NAME_PADD 21 static void stop_test(struct tst_job *job) { @@ -109,7 +109,7 @@ static void stop_test(struct tst_job *job) for (i = strlen(name); i < NAME_PADD; i++) fprintf(stderr, " "); - fprintf(stderr, " finished (Time %2i.%03is, CPU %2i.%03is) %sn", + fprintf(stderr, " finished (Time %3i.%03is, CPU %3i.%03is) %sn", sec, nsec/1000000, (int)job->cpu_time.tv_sec, (int)job->cpu_time.tv_nsec/1000000, @@ -215,14 +215,12 @@ static void prepare_tmpdir(const char *name, const char *res_path, static void write_timespec(struct tst_job *job, char type, struct timespec *time) { - char buf[1 + sizeof(time_t) + sizeof(long)]; + char buf[1 + sizeof(struct timespec)]; char *ptr = buf; *(ptr++) = type; - - *((time_t*)ptr) = time->tv_sec; - ptr += sizeof(time_t); - *((long*)ptr) = time->tv_nsec; + + memcpy(ptr, time, sizeof(*time)); if (write(job->pipefd, buf, sizeof(buf)) != sizeof(buf)) tst_warn("write(timespec) failed: %s", strerror(errno)); @@ -233,15 +231,14 @@ static void write_timespec(struct tst_job *job, char type, */ static void read_timespec(struct tst_job *job, struct timespec *time) { - char buf[sizeof(time_t) + sizeof(long)]; - char *ptr = buf; + int ret; - if (read(job->pipefd, buf, sizeof(buf)) != sizeof(buf)) - tst_warn("read(timespec) failed: %s", strerror(errno)); + do { + ret = read(job->pipefd, time, sizeof(*time)); + } while (ret == 0); - time->tv_sec = *((time_t*)ptr); - ptr += sizeof(time_t); - time->tv_nsec = *(long*)(ptr); + if (ret < 0 || ret != sizeof(*time)) + tst_warn("read(timespec) failed: %s", strerror(errno)); } static void child_write(struct tst_job *job, char ch, void *ptr, ssize_t size) ----------------------------------------------------------------------- Summary of changes: tests/framework/tst_job.c | 25 +++++++++++-------------- 1 files changed, 11 insertions(+), 14 deletions(-) repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive no reply. -- gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
0
0
[repo.or.cz] gfxprim.git branch master updated: c86751325f6076b6ea840a1a689b99e30f6c35ca
by metan
13 Oct '12
13 Oct '12
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 c86751325f6076b6ea840a1a689b99e30f6c35ca (commit) via 8bb3bbff3bf468349be5b2fdd18a3faf4e17a5cb (commit) via 39db9b12008710da657d2fe0aaf3486a2a497a8f (commit) from f6e4b62561d2fa6b7bcc94a24ba3fdaa1763aafe (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/c86751325f6076b6ea840a1a689b99e30f6c…
commit c86751325f6076b6ea840a1a689b99e30f6c35ca Author: Cyril Hrubis <metan(a)ucw.cz> Date: Sat Oct 13 15:26:19 2012 +0200 tests: Sketch gfx benchmarks. diff --git a/tests/Makefile b/tests/Makefile index f965da6..f4fc735 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,8 +1,9 @@ TOPDIR=.. include $(TOPDIR)/pre.mk -SUBDIRS=core SDL drivers framework loaders +SUBDIRS=core SDL drivers framework loaders gfx loaders: framework +gfx: framework include $(TOPDIR)/post.mk diff --git a/tests/gfx/Makefile b/tests/gfx/Makefile new file mode 100644 index 0000000..ec97b78 --- /dev/null +++ b/tests/gfx/Makefile @@ -0,0 +1,18 @@ +TOPDIR=../.. +include $(TOPDIR)/pre.mk + +CSOURCES=$(shell echo *.c) + +LDFLAGS+=-L../framework/ -L$(TOPDIR)/build/ +LDLIBS+=$(shell $(TOPDIR)/gfxprim-config --libs --libs-loaders) +LDLIBS+=-ltst_preload -ldl -ltst +CFLAGS+=-I../framework/ + +APPS=gfx_benchmark + +$(APPS): ../framework/libtst.a + +CLEAN+=log.html log.json + +include $(TOPDIR)/app.mk +include $(TOPDIR)/post.mk diff --git a/tests/gfx/gfx_benchmark.c b/tests/gfx/gfx_benchmark.c new file mode 100644 index 0000000..0ec61c6 --- /dev/null +++ b/tests/gfx/gfx_benchmark.c @@ -0,0 +1,142 @@ +/***************************************************************************** + * 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(a)ucw.cz> * + * * + *****************************************************************************/ + +#include <core/GP_Context.h> +#include <gfx/GP_Gfx.h> + +#include "tst_test.h" + +static int bench_line(GP_PixelType type) +{ + GP_Context *img = GP_ContextAlloc(800, 600, type); + + if (img == NULL) { + tst_report(0, "Malloc failed"); + return TST_INTERR; + } + + unsigned int i; + + for (i = 0; i < 100000; i++) { + GP_Line(img, 0 + i % 100, 0 - i % 100, + 800 - i%200, 600 + i%200, i % 0xff); + } + + return TST_SUCCESS; +} + +static int bench_line_1bpp(void) +{ + return bench_line(GP_PIXEL_G1); +} + +static int bench_line_2bpp(void) +{ + return bench_line(GP_PIXEL_G2); +} + +static int bench_line_4bpp(void) +{ + return bench_line(GP_PIXEL_G4); +} + +static int bench_line_8bpp(void) +{ + return bench_line(GP_PIXEL_G8); +} + +static int bench_line_32bpp(void) +{ + return bench_line(GP_PIXEL_RGB888); +} + +static int bench_circle(GP_PixelType type) +{ + GP_Context *img = GP_ContextAlloc(800, 600, type); + + if (img == NULL) { + tst_report(0, "Malloc failed"); + return TST_INTERR; + } + + unsigned int i; + + for (i = 0; i < 100000; i++) { + GP_Circle(img, img->w/2, img->h/2, i % 1000, i%0xff); + } + + return TST_SUCCESS; +} + +static int bench_circle_1bpp(void) +{ + return bench_circle(GP_PIXEL_G1); +} + +static int bench_circle_2bpp(void) +{ + return bench_circle(GP_PIXEL_G2); +} + +static int bench_circle_4bpp(void) +{ + return bench_circle(GP_PIXEL_G4); +} + +static int bench_circle_8bpp(void) +{ + return bench_circle(GP_PIXEL_G8); +} + +static int bench_circle_32bpp(void) +{ + return bench_circle(GP_PIXEL_RGB888); +} + +const struct tst_suite tst_suite = { + .suite_name = "GFX Benchmark", + .tests = { + {.name = "Line 1BPP", .tst_fn = bench_line_1bpp, + .bench_iter = 10}, + {.name = "Line 2BPP", .tst_fn = bench_line_2bpp, + .bench_iter = 10}, + {.name = "Line 4BPP", .tst_fn = bench_line_4bpp, + .bench_iter = 10}, + {.name = "Line 8BPP", .tst_fn = bench_line_8bpp, + .bench_iter = 10}, + {.name = "Line 32BPP", .tst_fn = bench_line_32bpp, + .bench_iter = 10}, + + {.name = "Circle 1BPP", .tst_fn = bench_circle_1bpp, + .bench_iter = 10}, + {.name = "Circle 2BPP", .tst_fn = bench_circle_2bpp, + .bench_iter = 10}, + {.name = "Circle 4BPP", .tst_fn = bench_circle_4bpp, + .bench_iter = 10}, + {.name = "Circle 8BPP", .tst_fn = bench_circle_8bpp, + .bench_iter = 10}, + {.name = "Circle 32BPP", .tst_fn = bench_circle_32bpp, + .bench_iter = 10}, + + {.name = NULL}, + } +}; diff --git a/tests/gfx/runtest.sh b/tests/gfx/runtest.sh new file mode 100755 index 0000000..71a411b --- /dev/null +++ b/tests/gfx/runtest.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# +# By default the glibc __libc_message() writes to /dev/tty before calling +# the abort(). Exporting this macro makes it to use stderr instead. +# +# The main usage of the function are malloc assertions, so this makes us catch +# the malloc error message by catching stderr output. +# +export LIBC_FATAL_STDERR_=1 + +LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./gfx_benchmark "$@"
http://repo.or.cz/w/gfxprim.git/commit/8bb3bbff3bf468349be5b2fdd18a3faf4e17…
commit 8bb3bbff3bf468349be5b2fdd18a3faf4e17a5cb Author: Cyril Hrubis <metan(a)ucw.cz> Date: Sat Oct 13 15:21:58 2012 +0200 tests: framework: Fix test job log output. Aling better the output on runtime >= 10 sec. diff --git a/tests/framework/test.c b/tests/framework/test.c index 69a9978..f4a8692 100644 --- a/tests/framework/test.c +++ b/tests/framework/test.c @@ -238,7 +238,7 @@ const struct tst_suite tst_suite = { {.name = "Failed FILE", .tst_fn = fail_FILE, .flags = TST_TMPDIR}, {.name = "Resource", .tst_fn = res_fn, .flags = TST_TMPDIR, .res_path = "test.c"}, - {.name = "Floating point exception", .tst_fn = fpe_fn}, + {.name = "FP exception", .tst_fn = fpe_fn}, {.name = "Benchmark test", .tst_fn = benchmark_fn, .bench_iter = 10}, {.name = NULL}, } diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c index a075c5f..c02fa9f 100644 --- a/tests/framework/tst_job.c +++ b/tests/framework/tst_job.c @@ -60,7 +60,7 @@ void tst_diff_timespec(int *sec, int *nsec, struct timespec *start, } } -#define NAME_PADD 24 +#define NAME_PADD 23 static void stop_test(struct tst_job *job) { @@ -109,7 +109,7 @@ static void stop_test(struct tst_job *job) for (i = strlen(name); i < NAME_PADD; i++) fprintf(stderr, " "); - fprintf(stderr, " finished (Time %i.%03is, CPU %i.%03is) %sn", + fprintf(stderr, " finished (Time %2i.%03is, CPU %2i.%03is) %sn", sec, nsec/1000000, (int)job->cpu_time.tv_sec, (int)job->cpu_time.tv_nsec/1000000, @@ -119,7 +119,7 @@ static void stop_test(struct tst_job *job) for (i = 0; i < NAME_PADD; i++) fprintf(stderr, " "); - fprintf(stderr, " bench CPU %i.%06is +/- %i.%06isn", + 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,
http://repo.or.cz/w/gfxprim.git/commit/39db9b12008710da657d2fe0aaf3486a2a49…
commit 39db9b12008710da657d2fe0aaf3486a2a497a8f Author: Cyril Hrubis <metan(a)ucw.cz> Date: Sat Oct 13 15:01:33 2012 +0200 tests: framework: Add benchmark logic. Now test could be marked as benchmark. Such functions is executed several times and mean and standard deviation are computed. diff --git a/tests/framework/Makefile b/tests/framework/Makefile index 709f907..7169bb7 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 +libtst.a: tst_test.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/test.c b/tests/framework/test.c index 48fa872..69a9978 100644 --- a/tests/framework/test.c +++ b/tests/framework/test.c @@ -207,6 +207,20 @@ static int fpe_fn(void) return 1/i; } +/* + * Let's benchmark memset. + */ +static int benchmark_fn(void) +{ + char buf[256]; + unsigned int i; + + for (i = 0; i < 4000000; i++) + memset(buf, i%100, sizeof(buf)); + + return TST_SUCCESS; +} + const struct tst_suite tst_suite = { .suite_name = "Testing Framework Example", .tests = { @@ -225,6 +239,7 @@ const struct tst_suite tst_suite = { {.name = "Resource", .tst_fn = res_fn, .flags = TST_TMPDIR, .res_path = "test.c"}, {.name = "Floating point exception", .tst_fn = fpe_fn}, + {.name = "Benchmark test", .tst_fn = benchmark_fn, .bench_iter = 10}, {.name = NULL}, } }; diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c index b27b358..a075c5f 100644 --- a/tests/framework/tst_job.c +++ b/tests/framework/tst_job.c @@ -30,10 +30,12 @@ #include <sys/types.h> #include <sys/wait.h> #include <stdarg.h> +#include <math.h> #include "tst_preload.h" #include "tst_test.h" #include "tst_job.h" +#include "tst_timespec.h" /* * Once we child forks to do a job, this points to its job structure. @@ -112,6 +114,17 @@ static void stop_test(struct tst_job *job) (int)job->cpu_time.tv_sec, (int)job->cpu_time.tv_nsec/1000000, result); + + if (job->bench_iter) { + for (i = 0; i < NAME_PADD; i++) + fprintf(stderr, " "); + + fprintf(stderr, " bench CPU %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); @@ -265,6 +278,69 @@ int tst_report(int level, const char *fmt, ...) return ret; } +/* + * Run benchmark job and compute result + */ +static int tst_job_benchmark(struct tst_job *job) +{ + unsigned int i, iter = job->test->bench_iter; + struct timespec cputime_start; + struct timespec cputime_stop; + struct timespec bench[iter]; + struct timespec sum = {.tv_sec = 0, .tv_nsec = 0}; + struct timespec dev = {.tv_sec = 0, .tv_nsec = 0}; + int ret; + + /* Warm up */ + ret = job->test->tst_fn(); + + if (ret) + return ret; + + /* Collect the data */ + for (i = 0; i < iter; i++) { + clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &cputime_start); + + ret = job->test->tst_fn(); + + if (ret) + return ret; + + clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &cputime_stop); + + timespec_sub(&cputime_stop, &cputime_start, &bench[i]); + + timespec_add(&bench[i], &sum); + } + + /* Compute mean */ + timespec_div(&sum, iter); + + double sum_d = timespec_to_double(&sum); + double dev_d = 0; + + /* And standard deviation */ + for (i = 0; i < iter; i++) { + double b = timespec_to_double(&bench[i]); + + b -= sum_d; + b = b * b; + + dev_d += b; + } + + dev_d /= iter; + dev_d = sqrt(dev_d); + + double_to_timespec(dev_d, &dev); + + /* Send data to parent */ + write_timespec(job, 'M', &sum); + write_timespec(job, 'D', &dev); + + return TST_SUCCESS; +} + void tst_job_run(struct tst_job *job) { int ret; @@ -280,6 +356,9 @@ void tst_job_run(struct tst_job *job) /* marks test as started */ start_test(job); + /* copy benchmark interation */ + job->bench_iter = job->test->bench_iter; + if (pipe(pipefd)) { tst_warn("pipefd() failed: %s", strerror(errno)); job->running = 0; @@ -335,7 +414,10 @@ void tst_job_run(struct tst_job *job) tst_malloc_check_start(); /* Run test */ - ret = job->test->tst_fn(); + if (job->test->bench_iter) + ret = tst_job_benchmark(job); + else + ret = job->test->tst_fn(); if (job->test->flags & TST_CHECK_MALLOC) { tst_malloc_check_stop(); @@ -426,6 +508,13 @@ void tst_job_wait(struct tst_job *job) case 'C': read_timespec(job, &job->cpu_time); break; + /* benchmark data */ + case 'M': + read_timespec(job, &job->bench_mean); + break; + case 'V': + read_timespec(job, &job->bench_var); + break; /* test message as generated by tst_report() */ case 'm': parent_read_msg(job); diff --git a/tests/framework/tst_job.h b/tests/framework/tst_job.h index 2e74a7d..76984e5 100644 --- a/tests/framework/tst_job.h +++ b/tests/framework/tst_job.h @@ -64,6 +64,11 @@ struct tst_job { /* test result */ enum tst_ret result; + /* additional benchmark data */ + unsigned int bench_iter; + struct timespec bench_mean; + struct timespec bench_var; + /* * test malloc statistics, filled if TST_MALLOC_CHECK was set. */ diff --git a/tests/framework/tst_log.c b/tests/framework/tst_log.c index 2991c0a..b1e43b8 100644 --- a/tests/framework/tst_log.c +++ b/tests/framework/tst_log.c @@ -186,6 +186,58 @@ static void malloc_stats_html(struct tst_job *job, FILE *f, const char *padd) fprintf(f, "%s</tr>n", padd); } +static void benchmark_stats_html(struct tst_job *job, FILE *f, const char *padd) +{ + /* Create innter table */ + fprintf(f, "%s<tr>n", padd); + fprintf(f, "%s <td bgcolor="#fd8" colspan="3">n", padd); + fprintf(f, "%s <center>n", padd); + fprintf(f, "%s <table>n", padd); + + /* Create header */ + fprintf(f, "%s <tr>n", padd); + + fprintf(f, "%s <td colspan="2" bgcolor="#fb2">n", padd); + fprintf(f, "%s <center><small>Benchmark data", padd); + fprintf(f, "</small></center>n"); + fprintf(f, "%s </td>n", padd); + + fprintf(f, "%s </tr>n", padd); + fprintf(f, "%s <tr>n", padd); + + fprintf(f, "%s <td bgcolor="#fc4">n", padd); + fprintf(f, "%s <center><small>Iterations", padd); + fprintf(f, "</small></center>n"); + fprintf(f, "%s </td>n", padd); + + fprintf(f, "%s <td bgcolor="#fc4">n", padd); + fprintf(f, "%s <center><small>Mean ∓ Variance", padd); + fprintf(f, "</small></center>n"); + fprintf(f, "%s </td>n", padd); + + fprintf(f, "%s </tr>n", padd); + + /* Create data */ + fprintf(f, "%s <tr>n", padd); + + fprintf(f, "%s <td bgcolor="#fc4">n", padd); + fprintf(f, "%s <center>%i</center>n", padd, job->bench_iter); + fprintf(f, "%s </td>n", padd); + + fprintf(f, "%s <td bgcolor="#fc4">n", padd); + fprintf(f, "%s <center>%i.%06is ∓ %i.%06is</center>n", padd, + (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); + fprintf(f, "%s </td>n", padd); + + fprintf(f, "%s </tr>n", padd); + + fprintf(f, "%s </table>n", padd); + fprintf(f, "%s </center>n", padd); + fprintf(f, "%s </td>n", padd); + fprintf(f, "%s</tr>n", padd); +} + static int append_html(struct tst_job *job, FILE *f) { const char *padd = " "; @@ -201,12 +253,15 @@ static int append_html(struct tst_job *job, FILE *f) bgcol = "#ddddee"; fprintf(f, "%s<tr>n", padd); - fprintf(f, "%s <td bgcolor="%s">%s </td>n", padd, bgcol, job->test->name); + fprintf(f, "%s <td bgcolor="%s">%s </td>n", + padd, bgcol, job->test->name); fprintf(f, "%s <td bgcolor="%s">n", padd, bgcol); - fprintf(f, "%s <center><small><font color="#222">%i.%03is %i.%03is</font></small></center>", - padd, sec, nsec/1000000, (int)job->cpu_time.tv_sec, (int)job->cpu_time.tv_nsec/1000000); + fprintf(f, "%s <center><small><font color="#222">%i.%03is %i.%03is" + "</font></small></center>n", padd, sec, nsec/1000000, + (int)job->cpu_time.tv_sec, (int)job->cpu_time.tv_nsec/1000000); fprintf(f, "%s </td>n", padd); - fprintf(f, "%s <td bgcolor="%s"><center><font color="white"> %s </td></center>n", padd, + fprintf(f, "%s <td bgcolor="%s"><center><font color="white">" + " %s </td></center>n", padd, ret_to_bg_color(job->result), ret_to_str(job->result)); struct tst_msg *msg; @@ -215,10 +270,14 @@ static int append_html(struct tst_job *job, FILE *f) if (job->test->flags & TST_CHECK_MALLOC) malloc_stats_html(job, f, padd); + if (job->bench_iter) + benchmark_stats_html(job, f, padd); + for (msg = job->store.first; msg != NULL; msg = msg->next) { fprintf(f, "%s<tr>n", padd); fprintf(f, "%s <td colspan="3" bgcolor="#eeeeee">n", padd); - fprintf(f, "%s <small>%s</small>n", padd, msg->msg); + fprintf(f, "%s <small>%s</small>n", + padd, msg->msg); fprintf(f, "%s </td>n", padd); fprintf(f, "%s</tr>n", padd); } @@ -268,6 +327,23 @@ static int append_malloc_stats_json(struct tst_job *job, FILE *f) return 0; } +static void append_benchmark_json(struct tst_job *job, FILE *f) +{ + fprintf(f, "ttt"Benchmark": {n"); + + fprintf(f, "tttt"Time Mean": %i.%09i,n", + (int)job->bench_mean.tv_sec, + (int)job->bench_mean.tv_nsec); + + fprintf(f, "tttt"Time Variance": %i.%09i,n", + (int)job->bench_var.tv_sec, + (int)job->bench_var.tv_nsec); + + fprintf(f, "tttt"Iterations": %in", job->bench_iter); + + fprintf(f, "ttt}n"); +} + static int hack_json_start = 0; static int append_json(struct tst_job *job, FILE *f) @@ -287,7 +363,11 @@ static int append_json(struct tst_job *job, FILE *f) /* If calculated include malloc report */ if (job->test->flags & TST_CHECK_MALLOC) append_malloc_stats_json(job, f); - + + /* If benchmark data were created */ + if (job->bench_iter) + append_benchmark_json(job, f); + /* Time statistics */ int sec, nsec; @@ -328,7 +408,8 @@ FILE *open_html(const struct tst_suite *suite, const char *path) if (f == NULL) return NULL; - fprintf(f, "<html>n <head>n </head>n <body>n <table bgcolor="#99a">n"); + fprintf(f, "<html>n <head>n </head>n <body>n " + "<table bgcolor="#99a">n"); fprintf(f, " <tr><td colspan="3" bgcolor="#bbbbff"><center><b>%s" "</b></center></td></tr>n", suite->suite_name); diff --git a/tests/framework/tst_test.h b/tests/framework/tst_test.h index 195b040..b9a0c17 100644 --- a/tests/framework/tst_test.h +++ b/tests/framework/tst_test.h @@ -57,6 +57,13 @@ struct tst_test { * test directory before test is executed. */ const char *res_path; + /* + * If not zero, the test is benchmark. + * + * The test_fn is executed bench_iter times and bench + * data are filled. + */ + unsigned int bench_iter; /* test function */ int (*tst_fn)(void); /* time limit in seconds 0 == unlimited */ diff --git a/tests/framework/tst_job.h b/tests/framework/tst_timespec.c similarity index 58% copy from tests/framework/tst_job.h copy to tests/framework/tst_timespec.c index 2e74a7d..d388502 100644 --- a/tests/framework/tst_job.h +++ b/tests/framework/tst_timespec.c @@ -20,72 +20,58 @@ * * *****************************************************************************/ - /* - - Test job is an instance of running test. +#include "tst_timespec.h" - */ +#define NSEC_IN_SEC 1000000000 -#ifndef TST_JOB_H -#define TST_JOB_H +double timespec_to_double(const struct timespec *t) +{ + double res; + + res = t->tv_sec; + res *= NSEC_IN_SEC; + res += t->tv_nsec; -#include <time.h> + return res; +} -#include "tst_msg.h" -#include "tst_preload.h" -#include "tst_test.h" +void double_to_timespec(const double time, struct timespec *res) +{ + res->tv_sec = time / NSEC_IN_SEC; + res->tv_nsec = time - res->tv_sec * NSEC_IN_SEC; +} -struct tst_job { - const struct tst_test *test; - - /* - * Pipe fd. - * - * In parent this points to the read side of the pipe so the parent - * recieves data from child. - * - * In child this points to the write side of the pipe so child can - * send data to parent. - */ - int pipefd; - - int running:1; - - /* test execution time */ - struct timespec start_time; - struct timespec stop_time; - - /* test cpu time */ - struct timespec cpu_time; +void timespec_sub(const struct timespec *a, const struct timespec *b, + struct timespec *res) +{ + res->tv_sec = a->tv_sec - b->tv_sec; + time_t nsec = a->tv_nsec; - /* test pid */ - int pid; - - /* test result */ - enum tst_ret result; + if (b->tv_nsec > a->tv_nsec) { + res->tv_sec--; + nsec += NSEC_IN_SEC; + } - /* - * test malloc statistics, filled if TST_MALLOC_CHECK was set. - */ - struct malloc_stats malloc_stats; + res->tv_nsec = nsec - b->tv_nsec; +} - /* store for test messages */ - struct tst_msg_store store; -}; +void timespec_add(const struct timespec *a, struct timespec *res) +{ + res->tv_sec += a->tv_sec; + res->tv_nsec += a->tv_nsec; -/* - * Runs a test job as a separate process. - * - * The test field must point to correct test. - */ -void tst_job_run(struct tst_job *job); + if (res->tv_nsec >= NSEC_IN_SEC) { + res->tv_sec += res->tv_nsec / NSEC_IN_SEC; + res->tv_nsec %= NSEC_IN_SEC; + } +} -/* - * Waits for the test to finish. - */ -void tst_job_wait(struct tst_job *job); +void timespec_div(struct timespec *res, unsigned int div) +{ + long sec = res->tv_sec; -void tst_diff_timespec(int *sec, int *nsec, struct timespec *start, - struct timespec *stop); + res->tv_sec /= div; + sec %= div; -#endif /* TST_JOB_H */ + res->tv_nsec = (sec * NSEC_IN_SEC + res->tv_nsec)/div; +} diff --git a/tests/framework/tst_job.h b/tests/framework/tst_timespec.h similarity index 58% copy from tests/framework/tst_job.h copy to tests/framework/tst_timespec.h index 2e74a7d..25d010c 100644 --- a/tests/framework/tst_job.h +++ b/tests/framework/tst_timespec.h @@ -22,70 +22,24 @@ /* - Test job is an instance of running test. + Timespec manipulation utils. */ -#ifndef TST_JOB_H -#define TST_JOB_H +#ifndef TST_TIMESPEC_H +#define TST_TIMESPEC_H #include <time.h> -#include "tst_msg.h" -#include "tst_preload.h" -#include "tst_test.h" +double timespec_to_double(const struct timespec *t); -struct tst_job { - const struct tst_test *test; - - /* - * Pipe fd. - * - * In parent this points to the read side of the pipe so the parent - * recieves data from child. - * - * In child this points to the write side of the pipe so child can - * send data to parent. - */ - int pipefd; - - int running:1; - - /* test execution time */ - struct timespec start_time; - struct timespec stop_time; - - /* test cpu time */ - struct timespec cpu_time; +void double_to_timespec(const double time, struct timespec *res); - /* test pid */ - int pid; - - /* test result */ - enum tst_ret result; +void timespec_sub(const struct timespec *a, const struct timespec *b, + struct timespec *res); - /* - * test malloc statistics, filled if TST_MALLOC_CHECK was set. - */ - struct malloc_stats malloc_stats; +void timespec_add(const struct timespec *a, struct timespec *res); - /* store for test messages */ - struct tst_msg_store store; -}; +void timespec_div(struct timespec *res, unsigned int div); -/* - * Runs a test job as a separate process. - * - * The test field must point to correct test. - */ -void tst_job_run(struct tst_job *job); - -/* - * Waits for the test to finish. - */ -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 */ +#endif /* TST_TIMESPEC_H */ ----------------------------------------------------------------------- Summary of changes: tests/Makefile | 3 +- tests/framework/Makefile | 2 +- tests/framework/test.c | 17 +++- tests/framework/tst_job.c | 95 +++++++++++++- tests/framework/tst_job.h | 5 + tests/framework/tst_log.c | 95 ++++++++++++- tests/framework/tst_test.h | 7 + tests/framework/{tst_msg.c => tst_timespec.c} | 77 +++++------ .../cpu_timer.h => tests/framework/tst_timespec.h | 39 +++--- tests/{loaders => gfx}/Makefile | 4 +- tests/gfx/gfx_benchmark.c | 142 ++++++++++++++++++++ tests/{loaders => gfx}/runtest.sh | 2 +- 12 files changed, 409 insertions(+), 79 deletions(-) copy tests/framework/{tst_msg.c => tst_timespec.c} (61%) copy demos/spiv/cpu_timer.h => tests/framework/tst_timespec.h (78%) copy tests/{loaders => gfx}/Makefile (83%) create mode 100644 tests/gfx/gfx_benchmark.c copy tests/{loaders => gfx}/runtest.sh (91%) repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive no reply. -- gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
0
0
[repo.or.cz] gfxprim.git branch master updated: f6e4b62561d2fa6b7bcc94a24ba3fdaa1763aafe
by metan
13 Oct '12
13 Oct '12
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 f6e4b62561d2fa6b7bcc94a24ba3fdaa1763aafe (commit) via bd67135bcd6d8ac8a8df924588988663837be998 (commit) via bbb09186311fc102ad68bfd94156ba4982176b83 (commit) from 9e00a730ea2ab2545b46298056b32841ad3500d4 (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/f6e4b62561d2fa6b7bcc94a24ba3fdaa1763…
commit f6e4b62561d2fa6b7bcc94a24ba3fdaa1763aafe Author: Cyril Hrubis <metan(a)ucw.cz> Date: Sat Oct 13 09:34:46 2012 +0200 tests: framework: Count correctly passed and skipped. diff --git a/tests/framework/tst_test.c b/tests/framework/tst_test.c index 2cc94a5..1981302 100644 --- a/tests/framework/tst_test.c +++ b/tests/framework/tst_test.c @@ -87,15 +87,19 @@ void tst_run_suite(const struct tst_suite *suite, const char *tst_name) if (tst_name == NULL || !strcmp(tst_name, suite->tests[i].name)) { ret = run_test(&suite->tests[i], html, json); counters[ret]++; - counter++; + + if (ret != TST_SKIPPED) + counter++; } } tst_log_close(html, TST_LOG_HTML); tst_log_close(json, TST_LOG_JSON); - fprintf(stderr, "nSummary: succedded %u out of %u (%.2f%%)n", - counters[0], counter, 100.00 * counters[0] / counter); + fprintf(stderr, "nSummary: succedded %u out of " + "%u %.2f%% (skipped %u)n", + counters[0], counter, 100.00 * counters[0] / counter, + counters[TST_SKIPPED]); } void tst_list_suite(const struct tst_suite *suite)
http://repo.or.cz/w/gfxprim.git/commit/bd67135bcd6d8ac8a8df924588988663837b…
commit bd67135bcd6d8ac8a8df924588988663837be998 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Fri Oct 12 23:44:37 2012 +0200 tests: framework: Add Floating Point Exception error. diff --git a/tests/framework/test.c b/tests/framework/test.c index a47d67d..48fa872 100644 --- a/tests/framework/test.c +++ b/tests/framework/test.c @@ -199,6 +199,14 @@ static int res_fn(void) return TST_SUCCESS; } +static int fpe_fn(void) +{ + /* its volatile so compiler doesn't detect the division by zero */ + volatile int i = 0; + + return 1/i; +} + const struct tst_suite tst_suite = { .suite_name = "Testing Framework Example", .tests = { @@ -216,6 +224,7 @@ const struct tst_suite tst_suite = { {.name = "Failed FILE", .tst_fn = fail_FILE, .flags = TST_TMPDIR}, {.name = "Resource", .tst_fn = res_fn, .flags = TST_TMPDIR, .res_path = "test.c"}, + {.name = "Floating point exception", .tst_fn = fpe_fn}, {.name = NULL}, } }; diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c index 79ae3e2..b27b358 100644 --- a/tests/framework/tst_job.c +++ b/tests/framework/tst_job.c @@ -87,6 +87,9 @@ static void stop_test(struct tst_job *job) 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; @@ -455,6 +458,13 @@ void tst_job_wait(struct tst_job *job) case SIGALRM: job->result = TST_TIMEOUT; break; + /* + * Floating point exception, most likely + * division by zero (including integer division) + */ + case SIGFPE: + job->result = TST_FPE; + break; /* * abort() called most likely double free or malloc data * corruption diff --git a/tests/framework/tst_log.c b/tests/framework/tst_log.c index 5ab46a6..2991c0a 100644 --- a/tests/framework/tst_log.c +++ b/tests/framework/tst_log.c @@ -44,6 +44,8 @@ static const char *ret_to_bg_color(enum tst_ret ret) return "#800080"; case TST_ABORTED: return "#e00000"; + case TST_FPE: + return "#e00000"; case TST_MEMLEAK: return "#a0a000"; case TST_FAILED: @@ -70,6 +72,8 @@ static const char *ret_to_str(enum tst_ret ret) return "Timeout"; case TST_ABORTED: return "Aborted"; + case TST_FPE: + return "FP Exception"; case TST_MEMLEAK: return "Memory Leak"; case TST_FAILED: diff --git a/tests/framework/tst_test.h b/tests/framework/tst_test.h index c329112..195b040 100644 --- a/tests/framework/tst_test.h +++ b/tests/framework/tst_test.h @@ -30,6 +30,7 @@ enum tst_ret { TST_SIGSEGV, /* Test ended with SIGSEGV */ TST_TIMEOUT, /* Test hasn't finished in time */ TST_ABORTED, /* The abort() was called (possible double free) */ + TST_FPE, /* Floating point exception */ TST_MEMLEAK, /* Memory leak was detected */ TST_FAILED, /* Test failed */ TST_MAX = TST_FAILED+1,
http://repo.or.cz/w/gfxprim.git/commit/bbb09186311fc102ad68bfd94156ba498217…
commit bbb09186311fc102ad68bfd94156ba4982176b83 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Fri Oct 12 22:32:59 2012 +0200 tests: framework: Add resource path. diff --git a/tests/framework/test.c b/tests/framework/test.c index 0e9e9df..a47d67d 100644 --- a/tests/framework/test.c +++ b/tests/framework/test.c @@ -191,6 +191,14 @@ static int skipped_fn(void) return TST_SKIPPED; } +static int res_fn(void) +{ + if (access("test.c", R_OK) == 0) + tst_report(0, "File correctly copied"); + + return TST_SUCCESS; +} + const struct tst_suite tst_suite = { .suite_name = "Testing Framework Example", .tests = { @@ -206,6 +214,8 @@ const struct tst_suite tst_suite = { {.name = "Double free()", .tst_fn = double_free}, {.name = "Barrier allocation", .tst_fn = barrier_allocation}, {.name = "Failed FILE", .tst_fn = fail_FILE, .flags = TST_TMPDIR}, + {.name = "Resource", .tst_fn = res_fn, .flags = TST_TMPDIR, + .res_path = "test.c"}, {.name = NULL}, } }; diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c index 227edd5..79ae3e2 100644 --- a/tests/framework/tst_job.c +++ b/tests/framework/tst_job.c @@ -146,16 +146,18 @@ static void remove_tmpdir(const char *path) } /* - * Create temp directory and cd into it + * Create temp directory and cd into it, copy resources if needed */ -static void create_tmpdir(const char *name, char *template, size_t size) +static void prepare_tmpdir(const char *name, const char *res_path, + char *template, size_t size) { - char safe_name[256]; + char tmp[256]; + int ret; /* Fix any funny characters in the test name */ - snprintf(safe_name, sizeof(safe_name), "%s", name); + snprintf(tmp, sizeof(tmp), "%s", name); - char *s = safe_name; + char *s = tmp; while (*s != '0') { if (!isalnum(*s)) @@ -164,13 +166,27 @@ static void create_tmpdir(const char *name, char *template, size_t size) } /* Create template from test name */ - snprintf(template, size, "/tmp/ctest_%s_XXXXXX", safe_name); + snprintf(template, size, "/tmp/ctest_%s_XXXXXX", tmp); if (mkdtemp(template) == NULL) { tst_warn("mkdtemp(%s) failed: %s", template, strerror(errno)); exit(TST_INTERR); } + /* Copy resources if needed */ + if (res_path != NULL) { + snprintf(tmp, sizeof(tmp), "cp -r '%s' '%s'", + res_path, template); + + ret = system(tmp); + + if (ret) { + tst_warn("failed to copy resource '%s'", res_path); + exit(TST_INTERR); + } + } + + if (chdir(template)) { tst_warn("chdir(%s) failed: %s", template, strerror(errno)); exit(TST_INTERR); @@ -297,7 +313,8 @@ void tst_job_run(struct tst_job *job) /* Create directory in /tmp/ and chdir into it. */ if (job->test->flags & TST_TMPDIR) - create_tmpdir(job->test->name, template, sizeof(template)); + prepare_tmpdir(job->test->name, job->test->res_path, + template, sizeof(template)); /* * If timeout is specified, setup alarm. diff --git a/tests/framework/tst_test.h b/tests/framework/tst_test.h index 4eb97e0..c329112 100644 --- a/tests/framework/tst_test.h +++ b/tests/framework/tst_test.h @@ -49,7 +49,13 @@ enum tst_flags { }; struct tst_test { + /* test name */ const char *name; + /* + * Resurce path, file or directory which is copied to + * test directory before test is executed. + */ + const char *res_path; /* test function */ int (*tst_fn)(void); /* time limit in seconds 0 == unlimited */ ----------------------------------------------------------------------- Summary of changes: tests/framework/test.c | 19 +++++++++++++++++++ tests/framework/tst_job.c | 41 ++++++++++++++++++++++++++++++++++------- tests/framework/tst_log.c | 4 ++++ tests/framework/tst_test.c | 10 +++++++--- tests/framework/tst_test.h | 7 +++++++ 5 files changed, 71 insertions(+), 10 deletions(-) repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive no reply. -- gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
0
0
[repo.or.cz] gfxprim.git branch master updated: 9e00a730ea2ab2545b46298056b32841ad3500d4
by metan
09 Oct '12
09 Oct '12
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 9e00a730ea2ab2545b46298056b32841ad3500d4 (commit) from 2370df5de0e544ff861f5c18a9ddb430d306301e (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/9e00a730ea2ab2545b46298056b32841ad35…
commit 9e00a730ea2ab2545b46298056b32841ad3500d4 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Wed Oct 3 16:44:29 2012 +0200 tests: framework: Fix typos & warnings. diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c index f483578..227edd5 100644 --- a/tests/framework/tst_job.c +++ b/tests/framework/tst_job.c @@ -116,7 +116,8 @@ static void stop_test(struct tst_job *job) /* Now print test message store */ tst_msg_print(&job->store); - fprintf(stderr, "------------------------------------------------------------------------------- n"); + fprintf(stderr, "------------------------------------------------------" + "------------------------- n"); } /* @@ -129,14 +130,19 @@ static void remove_tmpdir(const char *path) */ if (!strncmp("/tmp/", path, sizeof("/tmp/"))) { tst_warn("Path '%s' doesn't start with /tmp/, " - "ommiting cleanup", path); + "omitting cleanup", path); return; } //TODO: Cleaner solution? char buf[256]; + int ret; + snprintf(buf, sizeof(buf), "rm -rf '%s'", path); - (void)system(buf); + ret = system(buf); + + if (ret) + tst_warn("Failed to clean temp dir."); } /* @@ -146,7 +152,7 @@ static void create_tmpdir(const char *name, char *template, size_t size) { char safe_name[256]; - /* Fix any funny characters in test name */ + /* Fix any funny characters in the test name */ snprintf(safe_name, sizeof(safe_name), "%s", name); char *s = safe_name; @@ -160,7 +166,6 @@ static void create_tmpdir(const char *name, char *template, size_t size) /* Create template from test name */ snprintf(template, size, "/tmp/ctest_%s_XXXXXX", safe_name); - if (mkdtemp(template) == NULL) { tst_warn("mkdtemp(%s) failed: %s", template, strerror(errno)); exit(TST_INTERR); @@ -227,13 +232,16 @@ int tst_report(int level, const char *fmt, ...) va_start(va, fmt); ret = vsnprintf(buf+3, sizeof(buf) - 3, fmt, va); va_end(va); + + ssize_t size = ret > 255 ? 255 : ret + 1; buf[0] = 'm'; buf[1] = level; - ((unsigned char*)buf)[2] = ret > 255 ? 255 : ret + 1; + ((unsigned char*)buf)[2] = size; if (my_job != NULL) - write(my_job->pipefd, buf, (int)buf[2] + 3); + if (write(my_job->pipefd, buf, size + 3) != size + 3) + tst_warn("Failed to write msg to pipe."); return ret; } @@ -250,6 +258,7 @@ 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); if (pipe(pipefd)) { @@ -312,7 +321,8 @@ void tst_job_run(struct tst_job *job) tst_malloc_check_stop(); tst_malloc_check_report(&job->malloc_stats); - child_write(job, 's', &job->malloc_stats, sizeof(job->malloc_stats)); + child_write(job, 's', &job->malloc_stats, + sizeof(job->malloc_stats)); if (job->malloc_stats.lost_chunks != 0 && ret == TST_SUCCESS) ret = TST_MEMLEAK; @@ -344,7 +354,7 @@ static void parent_read_msg(struct tst_job *job) char buf[header[1]]; - if (read(job->pipefd, buf, sizeof(buf)) != sizeof(buf)) + if (read(job->pipefd, buf, sizeof(buf)) != (ssize_t)sizeof(buf)) tst_warn("parent: read(message) failed: %s", strerror(errno)); /* null-terminated the string, to be extra sure */ ----------------------------------------------------------------------- Summary of changes: tests/framework/tst_job.c | 28 +++++++++++++++++++--------- 1 files changed, 19 insertions(+), 9 deletions(-) repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive no reply. -- gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
0
0
← Newer
1
2
3
Older →
Jump to page:
1
2
3
Results per page:
10
25
50
100
200