mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
Fix occasional crash in test/libc/intrin/mmap_test (#1289)
This test would sometimes crash due to the EZBENCH2() macro occasionally running the first benchmark (BenchMmapPrivate()) less times than it does the second benchmark (BenchUnmap()) - this would then lead to a crash in BenchUnmap() because BenchUnmap() expects that BenchMmapPrivate() has to previously have been called at least as many times as it has itself such that a region of memory has been mapped, for BenchUnmap() to then unmap. This commit fixes this by utilizing the newer BENCHMARK() macro (instead of the EZBENCH2() macro) which runs the benchmark using an count of runs specified directly by the benchmark itself, which allows us to make sure that the two benchmark functions get ran the exact same amount of times.
This commit is contained in:
parent
19563d37c1
commit
7f21547122
1 changed files with 6 additions and 6 deletions
|
@ -32,7 +32,7 @@
|
|||
#include "libc/sysv/consts/msync.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
#include "libc/testlib/ezbench.h"
|
||||
#include "libc/testlib/benchmark.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/x/xspawn.h"
|
||||
|
||||
|
@ -524,7 +524,7 @@ TEST(mmap, sharedFileMapFork) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// BENCHMARKS
|
||||
|
||||
#define N (EZBENCH_COUNT * EZBENCH_TRIES)
|
||||
#define N 1000
|
||||
|
||||
int count;
|
||||
void *ptrs[N];
|
||||
|
@ -561,8 +561,8 @@ void BenchBigMunmap(void) {
|
|||
}
|
||||
|
||||
TEST(mmap, bench) {
|
||||
EZBENCH2("mmap", donothing, BenchMmapPrivate());
|
||||
EZBENCH2("munmap", donothing, BenchUnmap());
|
||||
// EZBENCH2("big mmap", donothing, BenchBigMmap());
|
||||
// EZBENCH2("big munmap", donothing, BenchBigMunmap());
|
||||
BENCHMARK(N, 1, BenchMmapPrivate());
|
||||
BENCHMARK(N, 1, BenchUnmap());
|
||||
// BENCHMARK(N, 1, BenchBigMmap());
|
||||
// BENCHMARK(N, 1, BenchBigMunmap());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue