How to reproduce
Run the following code:
#include <theft.h>
static enum theft_trial_res prop_arg_should_not_be_2 (
struct theft *t, void *arg)
{
return (*(int*)arg == 2) ? THEFT_TRIAL_FAIL : THEFT_TRIAL_PASS;
}
static enum theft_alloc_res alloc_random_int (
struct theft* t,
void* env,
void** instance)
{
*instance = malloc (sizeof (int));
*(int*)*instance = theft_random_choice (t, 4);
return THEFT_ALLOC_OK;
}
int main (void)
{
int status = 0;
struct theft_type_info test_info = {
.alloc = alloc_random_int,
.free = free,
};
struct theft_run_config config = {
.trials = 1000,
.name = "theft-random",
.prop1 = prop_arg_should_not_be_2,
.type_info = { &test_info },
.seed = theft_seed_of_time(),
};
if (theft_run (&config) != THEFT_RUN_PASS) status = 1;
return status;
}
Expected results
1/4 of the tests should fail and 3/4 should succeed. Some might be reported as duplicates (I don't know how theft determines duplicates exactly).
Actual results
Most of the time, theft reports 1 failure and 999 duplicates. Sometimes (rarely) there is 1 success. Example run:
== PROP 'theft-random': 1000 trials, seed 0x5634148fc7854230
-- Counter-Example: theft-random
Trial 0, Seed 0x5634148fc7854230
Fdddddddddd(DUP x 10)ddddddddd(DUP x 100)ddddddddd
== FAIL 'theft-random': pass 0, fail 1, skip 0, dup 999
Notes
I get the expected result for theft_random_choice (t, 5):
== PROP 'theft-random-05': 100 trials, seed 0x95aa7c8e00f2a039
..
-- Counter-Example: theft-random-05
Trial 2, Seed 0xc4dc214c16c339c8
F.......
skip several failure reports
-- Counter-Example: theft-random-05
Trial 86, Seed 0xf3275c78f72fba13
F.d..........d
== FAIL 'theft-random-05': pass 75, fail 17, skip 0, dup 8
A quick check with values from 2 to 20 shows funny results for all powers of two (see attached source):
theft-test.zip
> ./theft-test | grep '^== \(PASS\|FAIL\)'
== PASS 'theft-random-02': pass 1, fail 0, skip 0, dup 999
== FAIL 'theft-random-03': pass 317, fail 60, skip 0, dup 623
== PASS 'theft-random-04': pass 2, fail 0, skip 0, dup 998
== FAIL 'theft-random-05': pass 362, fail 32, skip 0, dup 606
== FAIL 'theft-random-06': pass 319, fail 62, skip 0, dup 619
== FAIL 'theft-random-07': pass 391, fail 27, skip 0, dup 582
== PASS 'theft-random-08': pass 2, fail 0, skip 0, dup 998
== FAIL 'theft-random-09': pass 385, fail 35, skip 0, dup 580
== FAIL 'theft-random-10': pass 375, fail 38, skip 0, dup 587
== PASS 'theft-random-11': pass 446, fail 0, skip 0, dup 554
== PASS 'theft-random-12': pass 434, fail 0, skip 0, dup 566
== PASS 'theft-random-13': pass 436, fail 0, skip 0, dup 564
== PASS 'theft-random-14': pass 443, fail 0, skip 0, dup 557
== PASS 'theft-random-15': pass 429, fail 0, skip 0, dup 571
== PASS 'theft-random-16': pass 2, fail 0, skip 0, dup 998
== FAIL 'theft-random-17': pass 384, fail 26, skip 0, dup 590
== FAIL 'theft-random-18': pass 380, fail 23, skip 0, dup 597
== FAIL 'theft-random-19': pass 378, fail 26, skip 0, dup 596
Version information
Running on Linux with gcc version 4.8.2:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.8/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.2-19ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-i386/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-i386 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-i386 --with-arch-directory=i386 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-targets=all --enable-multiarch --disable-werror --with-arch-32=i686 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
Current theft develop head: 0619c2a
How to reproduce
Run the following code:
Expected results
1/4 of the tests should fail and 3/4 should succeed. Some might be reported as duplicates (I don't know how theft determines duplicates exactly).
Actual results
Most of the time, theft reports 1 failure and 999 duplicates. Sometimes (rarely) there is 1 success. Example run:
Notes
I get the expected result for
theft_random_choice (t, 5):skip several failure reports
A quick check with values from 2 to 20 shows funny results for all powers of two (see attached source):
theft-test.zip
Version information
Running on Linux with gcc version 4.8.2:
Current theft
develophead: 0619c2a