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 07fc6dce72522e9b86d09dffb4c61be6db3a127c (commit) via 56000d2d040c16241af166e510bb72ec760fcfb6 (commit) from 285f37259943b8777104bf7e34e45cd1da2706a9 (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/07fc6dce72522e9b86d09dffb4c61be6db3a1...
commit 07fc6dce72522e9b86d09dffb4c61be6db3a127c Author: Cyril Hrubis metan@ucw.cz Date: Fri Sep 20 00:46:15 2013 +0200
test: framework: malloc check: Add realloc()
Use realloc to track malloced memory too.
Fixes warnings:
"Chunk passed to free not found (0x15c2650)"
When realloc was used to allocate memory. (found by TIFF loader tests)
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/tests/framework/tst_preload.c b/tests/framework/tst_preload.c index 6bb0c36..9205a66 100644 --- a/tests/framework/tst_preload.c +++ b/tests/framework/tst_preload.c @@ -126,8 +126,29 @@ void *malloc(size_t size)
void *ptr = real_malloc(size);
- if (check_malloc && ptr != NULL) + if (check_malloc && ptr) + add_chunk(size, ptr); + + return ptr; +} + +void *realloc(void *optr, size_t size) +{ + static void *(*real_realloc)(void*, size_t) = NULL; + + if (!real_realloc) + real_realloc = dlsym(RTLD_NEXT, "realloc"); + + void *ptr = real_realloc(optr, size); + + if (!ptr) + return NULL; + + if (check_malloc) { + if (optr) + rem_chunk(optr); add_chunk(size, ptr); + }
return ptr; }
http://repo.or.cz/w/gfxprim.git/commit/56000d2d040c16241af166e510bb72ec760fc...
commit 56000d2d040c16241af166e510bb72ec760fcfb6 Author: Cyril Hrubis metan@ucw.cz Date: Fri Sep 20 00:44:28 2013 +0200
tests: framework: Fix whitespaces.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/tests/framework/test.c b/tests/framework/test.c index 8111855..db42323 100644 --- a/tests/framework/test.c +++ b/tests/framework/test.c @@ -34,7 +34,7 @@ int success_fn(void) { tst_msg("This test does nothing"); tst_msg("But successfully"); - + return TST_SUCCESS; }
@@ -76,7 +76,7 @@ int temp_dir_fn(void) int malloc_leak_fn(void) { void *p, *q, *r; - + q = malloc(100); p = malloc(4); p = malloc(3); @@ -130,7 +130,7 @@ int barrier_allocation(void) buf[i] = 0;
tst_msg("About to use address after the buffer with barrier"); - + buf[31] = 0;
tst_msg("This is not printed at all"); @@ -150,7 +150,7 @@ int fail_FILE(void)
int fail = 0; FILE *f; - + f = fopen("test_fail_fclose", "w");
if (f == NULL) { @@ -182,7 +182,7 @@ int fail_FILE(void)
if (fail) return TST_FAILED; - + return TST_SUCCESS; }
@@ -191,7 +191,7 @@ static int messages_test_fn(void) /* stdout and stderr capture test */ printf("This is stdoutn"); fprintf(stderr, "This is stderrn"); - + tst_msg("This is message"); tst_warn("This is a warning"); tst_err("This is an error"); @@ -220,7 +220,7 @@ static int untested_fn(void)
static int res_fn(void) { - if (access("test.c", R_OK) == 0) + if (access("test.c", R_OK) == 0) tst_msg("File correctly copied");
return TST_SUCCESS; @@ -236,7 +236,7 @@ static int fpe_fn(void)
/* * Let's benchmark memset. - */ + */ static int benchmark_fn(void) { char buf[256]; diff --git a/tests/framework/tst_alloc_barriers.c b/tests/framework/tst_alloc_barriers.c index fb745b6..567e462 100644 --- a/tests/framework/tst_alloc_barriers.c +++ b/tests/framework/tst_alloc_barriers.c @@ -32,7 +32,7 @@ void *tst_alloc_barrier_right(size_t size) size_t pagesize = sysconf(_SC_PAGESIZE); size_t pages = size/pagesize + !!(size%pagesize) + 1; char *buf; - + if (posix_memalign((void*)&buf, pagesize, pages * pagesize)) return NULL;
@@ -70,11 +70,11 @@ void *tst_alloc_barrier_left(size_t size) size_t pages = size/pagesize + !!(size%pagesize) + 1;
char *buf; - + if (posix_memalign((void*)&buf, pagesize, pages * pagesize)) return NULL;
- /* + /* * Turn off read/write acces on the first page, the buffer starts right * after it. */ @@ -91,7 +91,7 @@ void tst_free_barrier_left(void *ptr, size_t size __attribute__((unused))) { size_t pagesize = sysconf(_SC_PAGESIZE); void *start = ptr - pagesize; - + /* Reset the memory protection back to RW */ if (mprotect(start, pagesize, PROT_READ | PROT_WRITE)) { perror("mprotect"); diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c index ca2b079..1d0d754 100644 --- a/tests/framework/tst_job.c +++ b/tests/framework/tst_job.c @@ -69,7 +69,7 @@ static void remove_tmpdir(const char *path) ret = system(buf);
if (ret) - tst_warn("Failed to clean temp dir."); + tst_warn("Failed to clean temp dir."); }
/* @@ -100,7 +100,7 @@ static void prepare_tmpdir(const char *name, const char *res_path, exit(TST_INTERR); }
- /* + /* * Copy resources if needed * * If resource is directory, copy only it's content. @@ -118,7 +118,7 @@ static void prepare_tmpdir(const char *name, const char *res_path,
if (S_ISDIR(st.st_mode)) p = "/*"; - + snprintf(tmp, sizeof(tmp), "cp -r '%s'%s '%s'", res_path, p, template);
@@ -148,7 +148,7 @@ static void write_timespec(struct tst_job *job, char type, char *ptr = buf;
*(ptr++) = type; - + memcpy(ptr, time, sizeof(*time));
if (write(job->pipefd, buf, sizeof(buf)) != sizeof(buf)) @@ -187,12 +187,12 @@ static int tst_vreport(int level, const char *fmt, va_list va) char buf[258];
ret = vsnprintf(buf+3, sizeof(buf) - 3, fmt, va); - + ssize_t size = ret > 255 ? 255 : ret + 1;
buf[0] = 'm'; buf[1] = level; - ((unsigned char*)buf)[2] = size; + ((unsigned char*)buf)[2] = size;
if (in_child()) { if (write(my_job->pipefd, buf, size + 3) != size + 3) @@ -221,7 +221,7 @@ int tst_msg(const char *fmt, ...) { va_list va; int ret; - + va_start(va, fmt);
if (in_child()) @@ -238,7 +238,7 @@ int tst_warn(const char *fmt, ...) { va_list va; int ret; - + va_start(va, fmt);
if (in_child()) @@ -255,7 +255,7 @@ int tst_err(const char *fmt, ...) { va_list va; int ret; - + va_start(va, fmt);
if (in_child()) @@ -292,24 +292,24 @@ static int tst_job_benchmark(struct tst_job *job) struct timespec sum = {.tv_sec = 0, .tv_nsec = 0}; struct timespec dev = {.tv_sec = 0, .tv_nsec = 0}; int ret; - + /* Warm up */ ret = job_run(job); - + if (ret) return ret;
/* Collect the data */ for (i = 0; i < iter; i++) { clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &cputime_start); - + ret = job_run(job); - + 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); @@ -317,17 +317,17 @@ static int tst_job_benchmark(struct tst_job *job)
/* 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; }
@@ -348,7 +348,7 @@ void tst_job_run(struct tst_job *job) int ret; char template[256]; int pipefd[2]; - + /* Write down starting time of the test */ clock_gettime(CLOCK_MONOTONIC, &job->start_time);
@@ -397,7 +397,7 @@ void tst_job_run(struct tst_job *job) prepare_tmpdir(job->test->name, job->test->res_path, template, sizeof(template));
- /* + /* * If timeout is specified, setup alarm. * * If alarm fires the test will be killed by SIGALRM. @@ -486,7 +486,7 @@ void tst_job_read(struct tst_job *job) if (ret < 0) { tst_warn("job_read: read() failed: %s", strerror(errno)); job->running = 0; - + //TODO: kill the process?
return; @@ -498,9 +498,9 @@ void tst_job_read(struct tst_job *job) tst_warn("job_read: read() returned EAGAIN"); return; } - + job->running = 0; - + return; }
@@ -566,7 +566,7 @@ void tst_job_collect(struct tst_job *job) case SIGFPE: job->result = TST_FPE; break; - /* + /* * abort() called most likely double free or malloc data * corruption */ @@ -578,7 +578,7 @@ void tst_job_collect(struct tst_job *job) job->result = TST_INTERR; } } - + /* Write down stop time */ clock_gettime(CLOCK_MONOTONIC, &job->stop_time); } diff --git a/tests/framework/tst_log.c b/tests/framework/tst_log.c index aecb8dc..658419e 100644 --- a/tests/framework/tst_log.c +++ b/tests/framework/tst_log.c @@ -105,7 +105,7 @@ static void append_benchmark_json(struct tst_job *job, FILE *f) 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); @@ -143,12 +143,12 @@ int tst_log_append(struct tst_job *job, FILE *f) int sec, nsec;
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);
fprintf(f, "ttt"Run Time": %i.%09in", sec, nsec); - + fprintf(f, "tt}");
return 0; @@ -161,14 +161,14 @@ static void write_system_info_json(FILE *f) uname(&buf);
fprintf(f, "t"System Info": {n"); - + fprintf(f, "tt"OS": "%s",n", buf.sysname); fprintf(f, "tt"Hostname": "%s",n", buf.nodename); fprintf(f, "tt"Release": "%s",n", buf.release);
/* CPU related info */ fprintf(f, "tt"CPU": {"); - + /* lscpu is part of reasonably new util-linux */ FILE *cmd = popen("lscpu 2> /dev/null", "r");
@@ -180,11 +180,11 @@ static void write_system_info_json(FILE *f) fprintf(f, "%sttt"%s": "%s"", del, id, val); del = ",n"; } - + fclose(cmd); fprintf(f, "n"); } - + fprintf(f, "tt}n");
fprintf(f, "t},n"); diff --git a/tests/framework/tst_main.c b/tests/framework/tst_main.c index a45b2c6..a06ee82 100644 --- a/tests/framework/tst_main.c +++ b/tests/framework/tst_main.c @@ -72,7 +72,7 @@ int main(int argc, char *argv[]) return 1; } } - + tst_run_suite(&tst_suite, NULL);
return 0; diff --git a/tests/framework/tst_msg.c b/tests/framework/tst_msg.c index 8deafd1..b4f150f 100644 --- a/tests/framework/tst_msg.c +++ b/tests/framework/tst_msg.c @@ -48,7 +48,7 @@ int tst_msg_append(struct tst_msg_store *self, int type, const char *msg_text) { size_t len = strlen(msg_text); struct tst_msg *msg; - + msg = malloc(sizeof(struct tst_msg) + len + 1);
if (msg == NULL) { diff --git a/tests/framework/tst_preload.c b/tests/framework/tst_preload.c index aec364f..6bb0c36 100644 --- a/tests/framework/tst_preload.c +++ b/tests/framework/tst_preload.c @@ -52,10 +52,10 @@ void tst_malloc_check_report(struct malloc_stats *stats) { stats->total_size = total_size; stats->total_chunks = total_chunks; - + stats->max_size = max_size; stats->max_chunks = max_chunks; - + stats->lost_size = cur_size; stats->lost_chunks = cur_chunks; } @@ -103,14 +103,13 @@ static void rem_chunk(void *ptr)
for (i = 0; i < chunks_top; i++) { if (chunks[i].ptr == ptr) { - /* Update global stats */ cur_size -= chunks[i].size; cur_chunks--; - + /* Replace found chunk with top one */ chunks[i] = chunks[--chunks_top]; - + return; } } @@ -139,7 +138,7 @@ void free(void *ptr)
if (!real_free) real_free = dlsym(RTLD_NEXT, "free"); - + if (check_malloc && ptr != NULL) rem_chunk(ptr);
diff --git a/tests/framework/tst_preload_FILE.c b/tests/framework/tst_preload_FILE.c index 2365b6b..1d546a2 100644 --- a/tests/framework/tst_preload_FILE.c +++ b/tests/framework/tst_preload_FILE.c @@ -43,7 +43,7 @@ static struct tst_fail_FILE *failure_by_path(const char *path,
if (failures == NULL) return NULL; - + for (i = 0; failures[i].path != NULL; i++) if (failures[i].call == call && !strcmp(path, failures[i].path)) @@ -58,7 +58,7 @@ void failures_init_FILE(const char *path, FILE *f)
if (failures == NULL) return; - + //TODO: warn on f not NULL for (i = 0; failures[i].path != NULL; i++) if (!strcmp(path, failures[i].path)) @@ -68,7 +68,7 @@ void failures_init_FILE(const char *path, FILE *f) static struct tst_fail_FILE *failure_by_FILE(FILE *f, enum tst_file_call call) { unsigned int i; - + if (failures == NULL) return NULL;
@@ -109,19 +109,19 @@ int fclose(FILE *fp)
if (!real_fclose) real_fclose = dlsym(RTLD_NEXT, "fclose"); - + struct tst_fail_FILE *failure = failure_by_FILE(fp, TST_FAIL_FCLOSE);
- /* + /* * We close the file here correctly, we can because when fclose() has * failed any further access results in undefined behavior. */ if (failure) { real_fclose(fp); - + if (failure->err) errno = failure->err; - + return EOF; }
diff --git a/tests/framework/tst_suite.c b/tests/framework/tst_suite.c index 2bb8455..6088db3 100644 --- a/tests/framework/tst_suite.c +++ b/tests/framework/tst_suite.c @@ -47,7 +47,7 @@ static void test_job_report(const struct tst_job *job) 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) { @@ -84,9 +84,9 @@ static void test_job_report(const struct tst_job *job) case TST_MAX: break; } - + fprintf(stderr, "e[1;37m%se[0m", name); - + int i;
for (i = strlen(name); i < NAME_PADD; i++) @@ -94,7 +94,7 @@ static void test_job_report(const struct tst_job *job)
fprintf(stderr, " finished (Time %3i.%03is) %sn", sec, nsec/1000000, result); - + if (job->bench_iter) { for (i = 0; i < NAME_PADD; i++) fprintf(stderr, " "); @@ -111,7 +111,7 @@ static void test_job_report(const struct tst_job *job)
/* Now print test message store */ tst_msg_print(&job->store); - + fprintf(stderr, "------------------------------------------------------" "------------------------- n"); } @@ -122,7 +122,7 @@ static int run_test(const struct tst_test *test, FILE *json)
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 @@ -133,7 +133,7 @@ static int run_test(const struct tst_test *test, FILE *json)
tst_job_run(&job); tst_job_wait(&job); - + /* report result into stdout */ test_job_report(&job);
@@ -156,7 +156,7 @@ void tst_run_suite(const struct tst_suite *suite, const char *tst_name) fprintf(stderr, "Running e[1;37m%se[0mnn", suite->suite_name);
FILE *json = NULL; - + if (tst_log_dir) { char buf[512]; snprintf(buf, sizeof(buf), "%s/%s.json", @@ -168,7 +168,7 @@ 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], json); counters[ret]++; - + if (ret != TST_SKIPPED) counter++; } @@ -178,7 +178,7 @@ void tst_run_suite(const struct tst_suite *suite, const char *tst_name) tst_log_close(json);
float percents; - + if (counter == 0) percents = 100; else diff --git a/tests/framework/tst_timespec.c b/tests/framework/tst_timespec.c index 233095c..45a4422 100644 --- a/tests/framework/tst_timespec.c +++ b/tests/framework/tst_timespec.c @@ -40,7 +40,7 @@ void timespec_diff(int *sec, int *nsec, double timespec_to_double(const struct timespec *t) { double res; - + res = t->tv_sec; res *= NSEC_IN_SEC; res += t->tv_nsec;
-----------------------------------------------------------------------
Summary of changes: tests/framework/test.c | 16 +++++----- tests/framework/tst_alloc_barriers.c | 8 +++--- tests/framework/tst_job.c | 48 +++++++++++++++++----------------- tests/framework/tst_log.c | 14 +++++----- tests/framework/tst_main.c | 2 +- tests/framework/tst_msg.c | 2 +- tests/framework/tst_preload.c | 34 +++++++++++++++++++----- tests/framework/tst_preload_FILE.c | 14 +++++----- tests/framework/tst_suite.c | 20 +++++++------- tests/framework/tst_timespec.c | 2 +- 10 files changed, 90 insertions(+), 70 deletions(-)
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.