Skip to content

Commit

Permalink
test: better win compat
Browse files Browse the repository at this point in the history
  • Loading branch information
rurban committed Feb 29, 2024
1 parent 0227818 commit b865a8e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion source/algos/ssecp.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void compute(unsigned char *x, int m, int *mu, int *pi) {
}

// algorithm is not exactly like paper- allow overflow anchor match.
// todo: double up loops to avoid the one comparison for the length
// TODO: double up loops to avoid the one comparison for the length

int search(unsigned char *x, int m, unsigned char *y, int n) {
if (m <= max_needle) // raw SSE instructions for short patterns
Expand Down
31 changes: 21 additions & 10 deletions source/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,21 @@ void printManual() {
printf("\n\n");
}

int execute(char *algoname, key_t pkey, int m, key_t tkey, int n, key_t rkey,
key_t ekey, key_t prekey, int *count, int alpha) {

int execute(
#ifdef _WIN32
char *algoname, unsigned char *P, int m, unsigned char *T, int n,
int *count
#else
char *algoname, key_t pkey, int m, key_t tkey, int n, key_t rkey,
key_t ekey, key_t prekey, int *count, int alpha
#endif
)
{
char command[100];
#ifdef _WIN32
(void)rkey; (void)ekey; (void)prekey;
sprintf(command, "./source/bin/%s %d %d %d %d", algoname,
pkey, m, tkey, n);
sprintf(command, "./source/bin/%s %s %d %s %d", algoname,
P, m, T, n);
#else
sprintf(command, "./source/bin/%s shared %d %d %d %d %d %d %d", algoname,
pkey, m, tkey, n, rkey, ekey, prekey);
Expand Down Expand Up @@ -115,13 +123,16 @@ int attempt(int *rip, int *count, unsigned char *P, int m, unsigned char *T,
// printf("\b\b\b\b\b\b[%.3d%%]",(*rip)*100/18); fflush(stdout);
(*count) = 0;
int occur1 = search(P, m, T, n);
int occur2 =
execute(algoname, pkey, m, tkey, n, rkey, ekey, prekey, count, alpha);
#ifdef _WIN32
int occur2 = execute(algoname, P, m, T, n, count);
#else
int occur2 = execute(algoname, pkey, m, tkey, n, rkey, ekey, prekey, count, alpha);
#endif
if (occur2 >= 0 && occur1 != occur2) {
if (!VERBOSE)
printf("\n\tERROR: test failed on case n.%d (\"%s\" in \"%s\")\n\
found %d occ instead of %d\n\n",
ncase, P, T, occur2, occur1);
printf("\n\tERROR: test failed on case n.%d (m=%d,n=%d) (\"%s\" in \"%s\")\n"
"found %d occ instead of %d\n\n",
ncase, m, n, P, T, occur2, occur1);
free_shm();
return 0;
}
Expand Down

0 comments on commit b865a8e

Please sign in to comment.