-
Notifications
You must be signed in to change notification settings - Fork 115
Run oracle program C tests from Rust #349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,7 @@ qcmp( void const * _p, | |
return 0; | ||
} | ||
|
||
int | ||
main( int argc, | ||
char ** argv ) { | ||
(void)argc; (void)argv; | ||
int test_price_model() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the changes in the C test files are:
|
||
|
||
prng_t _prng[1]; | ||
prng_t * prng = prng_join( prng_new( _prng, (uint32_t)0, (uint64_t)0 ) ); | ||
|
@@ -29,10 +26,7 @@ main( int argc, | |
int64_t val [3]; | ||
int64_t scratch[N]; | ||
|
||
int ctr = 0; | ||
for( int iter=0; iter<10000000; iter++ ) { | ||
if( !ctr ) { printf( "Completed %u iterations\n", iter ); ctr = 100000; } | ||
ctr--; | ||
|
||
/* Generate a random test */ | ||
|
||
|
@@ -63,6 +57,5 @@ main( int argc, | |
|
||
prng_delete( prng_leave( prng ) ); | ||
|
||
printf( "pass\n" ); | ||
return 0; | ||
} |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,7 @@ | |
#define SORT_BEFORE(i,j) BEFORE(i,j) | ||
#include "tmpl/sort_stable.c" | ||
|
||
int | ||
main( int argc, | ||
char ** argv ) { | ||
(void)argc; (void)argv; | ||
int test_sort_stable() { | ||
|
||
# define N 96 | ||
int x[N]; | ||
|
@@ -23,7 +20,6 @@ main( int argc, | |
additional information in the keys to validate stability as well). */ | ||
|
||
for( int n=0; n<=24; n++ ) { | ||
printf( "Zero-One: Testing n=%i\n", n ); | ||
for( long b=0L; b<(1L<<n); b++ ) { | ||
for( int i=0; i<n; i++ ) x[i] = (((int)((b>>i) & 1L))<<16) | i; | ||
for( int i=0; i<n; i++ ) w[i] = x[i]; | ||
|
@@ -49,10 +45,7 @@ main( int argc, | |
prng_t _prng[1]; | ||
prng_t * prng = prng_join( prng_new( _prng, (uint32_t)0, (uint64_t)0 ) ); | ||
|
||
int ctr = 0; | ||
for( int iter=0; iter<10000000; iter++ ) { | ||
if( !ctr ) { printf( "Randomized: Completed %i iterations\n", iter ); ctr = 100000; } | ||
ctr--; | ||
|
||
int n = (int)(prng_uint32( prng ) % (uint32_t)(N+1)); /* In [0,N], approx uniform IID */ | ||
for( int i=0; i<n; i++ ) x[i] = (int)((prng_uint32( prng ) & UINT32_C( 0x00ff0000 )) | (uint32_t)i); | ||
|
@@ -74,8 +67,6 @@ main( int argc, | |
} | ||
|
||
prng_delete( prng_leave( prng ) ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean to delete this |
||
|
||
printf( "pass\n" ); | ||
return 0; | ||
} | ||
|
||
|
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,19 +2,11 @@ | |
#include "util.h" | ||
|
||
int | ||
main( int argc, | ||
char ** argv ) { | ||
(void)argc; (void)argv; | ||
|
||
test_avg() { | ||
prng_t _prng[1]; | ||
prng_t * prng = prng_join( prng_new( _prng, (uint32_t)0, (uint64_t)0 ) ); | ||
|
||
int ctr; | ||
|
||
ctr = 0; | ||
for( int i=0; i<1000000000; i++ ) { | ||
if( !ctr ) { printf( "reg: Completed %i iterations\n", i ); ctr = 10000000; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can delete |
||
ctr--; | ||
for( int i=0; i<100000000; i++ ) { | ||
|
||
# define TEST(w) do { \ | ||
uint##w##_t x = prng_uint##w( prng ); \ | ||
|
@@ -75,18 +67,15 @@ main( int argc, | |
|
||
# define N 512 | ||
|
||
ctr = 0; | ||
for( int i=0; i<10000000; i++ ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's another variable called |
||
if( !ctr ) { printf( "mem: Completed %i iterations\n", i ); ctr = 100000; } | ||
ctr--; | ||
for( int i=0; i<1000000; i++ ) { | ||
|
||
# define TEST(w) do { \ | ||
uint##w##_t x[N]; \ | ||
uint32_t n = prng_uint32( prng ) & (uint32_t)(N-1); \ | ||
uint64_t a = (uint64_t)0; \ | ||
for( uint32_t i=(uint32_t)0; i<n; i++ ) { \ | ||
for( uint32_t j=(uint32_t)0; j<n; j++ ) { \ | ||
uint##w##_t xi = prng_uint##w( prng ); \ | ||
x[i] = xi; \ | ||
x[j] = xi; \ | ||
a += (uint64_t)xi; \ | ||
} \ | ||
if( n ) a /= (uint64_t)n; \ | ||
|
@@ -109,9 +98,9 @@ main( int argc, | |
int##w##_t x[N]; \ | ||
uint32_t n = prng_uint32( prng ) & (uint32_t)(N-1); \ | ||
int64_t a = (int64_t)0; \ | ||
for( uint32_t i=(uint32_t)0; i<n; i++ ) { \ | ||
for( uint32_t j=(uint32_t)0; j<n; j++ ) { \ | ||
int##w##_t xi = (int##w##_t)prng_uint##w( prng ); \ | ||
x[i] = xi; \ | ||
x[j] = xi; \ | ||
a += (int64_t)xi; \ | ||
} \ | ||
if( n ) a /= (int64_t)n; /* Assumes round to zero signed int div on platform */ \ | ||
|
@@ -136,7 +125,5 @@ main( int argc, | |
|
||
prng_delete( prng_leave( prng ) ); | ||
|
||
printf( "pass\n" ); | ||
|
||
return 0; | ||
} |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that build-bpf.sh above runs cargo test-bpf, which now runs all of these tests.