Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Fix up lj_str_hash smoke tests
Browse files Browse the repository at this point in the history
Make the lj_str_hash test include and run the right sources.  This
should go into $srcdir/tests/ in my repo but keep it here for now.
  • Loading branch information
siddhesh committed Sep 16, 2019
1 parent e44776b commit c7e0e64
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/lj_str_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "lj_jit.h"
#include "lj_arch.h"

#ifdef LJ_HAS_OPTIMISED_HASH
#if defined(LJ_HAS_OPTIMISED_HASH) || defined(SMOKETEST)
#if !defined(__SSE4_2__)
#error "This file must be built with -msse4.2"
#endif
Expand Down Expand Up @@ -268,7 +268,9 @@ static LJ_AINLINE uint32_t lj_str_hash_opt(const char* str, size_t len)
void lj_str_hash_init(uint32_t flags)
{
if (flags & JIT_F_SSE4_2) {
#ifndef SMOKETEST
lj_str_hash = lj_str_hash_opt;
#endif
str_hash_init_random();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/x64/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ CXXFLAGS := -O3 -MD -g -msse4.2 -Wall -I../src -I../../../src
test: $(TEST_PROGRAM)
@echo "some unit test"
$(VALGRIND) ./$(TEST_PROGRAM)
./unit_test.sh
bash ./unit_test.sh

@echo "smoke test"
../../luajit test_str_comp.lua
Expand Down
7 changes: 5 additions & 2 deletions src/x64/test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
#include <stdlib.h>
#include <map>
#include "test_util.hpp"
#include "lj_str_hash_x64.h"

#define SMOKETEST
#include "../../lj_str_hash.c"

using namespace std;

static bool
smoke_test()
{
lj_str_hash_init(JIT_F_SSE4_2);
fprintf(stdout, "running smoke tests...\n");
char buf[1024];
char c = getpid() % 'a';
Expand All @@ -22,7 +25,7 @@ smoke_test()
255, 256, 257};
for (unsigned i = 0; i < sizeof(lens)/sizeof(lens[0]); i++) {
string s(buf, lens[i]);
test_printf("%d", lj_str_hash(s.c_str(), lens[i]));
test_printf("%d", lj_str_hash_opt(s.c_str(), lens[i]));
}

return true;
Expand Down

0 comments on commit c7e0e64

Please sign in to comment.