Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ jobs:
- name: test-all
if: always()
run: |
make clean test-all
make clean test-all MOREFLAGS="-Wconversion -Werror"

- name: test-alias
run: |
Expand Down Expand Up @@ -237,7 +237,6 @@ jobs:
- name: tests/bench
run: |
make -C tests/bench
make -C tests/bench clean main.o CC=gcc MOREFLAGS="-Wconversion -Werror"


ubuntu-wasm:
Expand Down
2 changes: 2 additions & 0 deletions cli/xsum_os_specific.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ static wchar_t* XSUM_widenString(const char* str, int* lenOut)
* Converts a UTF-16 string to UTF-8. Acts like strdup. The string must be freed afterwards.
* This version allows keeping the output length.
*/
#ifndef XSUM_NO_MAIN
static char* XSUM_narrowString(const wchar_t *str, int *lenOut)
{
int len = WideCharToMultiByte(CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL);
Expand All @@ -200,6 +201,7 @@ static char* XSUM_narrowString(const wchar_t *str, int *lenOut)
return buf;
}
}
#endif



Expand Down
2 changes: 1 addition & 1 deletion tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# ################################################################

MAKEFLAGS += --no-print-directory
CFLAGS += -Wall -Wextra -Wundef -g
CFLAGS += -Wall -Wextra -Wundef -g $(MOREFLAGS)

CP = cp
NM = nm
Expand Down
2 changes: 1 addition & 1 deletion tests/bench/benchHash.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ bench_hash_internal(BMK_benchFn_t hashfn, void* payload,

free(srcBuffer);
assert(runTime.nanoSecPerRun != 0);
return (1000000000U / runTime.nanoSecPerRun) * nbBlocks;
return (1000000000U / runTime.nanoSecPerRun) * (double)nbBlocks;

}

Expand Down
6 changes: 3 additions & 3 deletions tests/bench/benchfn.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,17 @@ BMK_runOutcome_t BMK_benchTimedFn(BMK_timedFnState_t* cont,
cont->timeSpent_ns += (unsigned long long)loopDuration_ns;

/* estimate nbLoops for next run to last approximately 1 second */
if (loopDuration_ns > (runBudget_ns / 50)) {
if (loopDuration_ns > (double)(runBudget_ns / 50)) {
double const fastestRun_ns = MIN(bestRunTime.nanoSecPerRun, newRunTime.nanoSecPerRun);
cont->nbLoops = (unsigned)(runBudget_ns / fastestRun_ns) + 1;
cont->nbLoops = (unsigned)((double)runBudget_ns / fastestRun_ns) + 1;
} else {
/* previous run was too short : blindly increase workload by x multiplier */
const unsigned multiplier = 10;
assert(cont->nbLoops < ((unsigned)-1) / multiplier); /* avoid overflow */
cont->nbLoops *= multiplier;
}

if (loopDuration_ns < runTimeMin_ns) {
if (loopDuration_ns < (double)runTimeMin_ns) {
/* When benchmark run time is too small : don't report results.
* increased risks of rounding errors */
continue;
Expand Down
2 changes: 1 addition & 1 deletion tests/bench/bhDisplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static void bench_oneHash_largeInput(Bench_Entry hashDesc, int minlog, int maxlo
double const nbhps = bench_hash(hashDesc.hash, BMK_throughput,
inputSize, BMK_fixedSize,
BENCH_LARGE_TOTAL_MS, BENCH_LARGE_ITER_MS);
printf(",%6.0f", nbhps * inputSize / MB_UNIT); fflush(NULL);
printf(",%6.0f", nbhps * (double)inputSize / MB_UNIT); fflush(NULL);
}
printf("\n");
}
Expand Down
12 changes: 10 additions & 2 deletions tests/bench/timefn.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,16 @@ PTime UTIL_getSpanTimeNano(UTIL_time_t begin, UTIL_time_t end)
#else /* relies on standard C90 (note : clock_t measurements can be wrong when using multi-threading) */

UTIL_time_t UTIL_getTime(void) { return clock(); }
PTime UTIL_getSpanTimeMicro(UTIL_time_t clockStart, UTIL_time_t clockEnd) { return 1000000ULL * (clockEnd - clockStart) / CLOCKS_PER_SEC; }
PTime UTIL_getSpanTimeNano(UTIL_time_t clockStart, UTIL_time_t clockEnd) { return 1000000000ULL * (clockEnd - clockStart) / CLOCKS_PER_SEC; }

PTime UTIL_getSpanTimeMicro(UTIL_time_t clockStart, UTIL_time_t clockEnd)
{
return 1000000ULL * (PTime)(clockEnd - clockStart) / CLOCKS_PER_SEC;
}

PTime UTIL_getSpanTimeNano(UTIL_time_t clockStart, UTIL_time_t clockEnd)
{
return 1000000000ULL * (PTime)(clockEnd - clockStart) / CLOCKS_PER_SEC;
}

#endif

Expand Down
4 changes: 2 additions & 2 deletions tests/collisions/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
HEADER_DIRS = ./ ../../ allcodecs/
CPPFLAGS += $(addprefix -I ,$(HEADER_DIRS))
CFLAGS += -Wall -Wextra -Wconversion \
-std=c11
-std=c11 $(MOREFLAGS)
CXXFLAGS += -Wall -Wextra -Wconversion \
-std=c++11
-std=c++11 $(MOREFLAGS)
LDFLAGS += -pthread
TESTHASHES = 3200000

Expand Down
3 changes: 2 additions & 1 deletion tests/collisions/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ static size_t search_collisions(
int const hwidth = hashfnTable[hashID].bits;
if (totalH == 0) totalH = select_nbh(hwidth);
if (bflog == 0) bflog = highestBitSet(totalH) + 1; /* auto-size filter */
uint64_t const bfsize = (1ULL << bflog);
assert(!filter || (0 <= bflog && bflog < 64));


/* === filter hashes (optional) === */
Expand All @@ -696,6 +696,7 @@ static size_t search_collisions(
uint64_t maxNbH = totalH;

if (filter) {
uint64_t const bfsize = 1ULL << bflog;
time_t const filterTBegin = time(NULL);
DISPLAY(" Creating filter (%i GB) \n", (int)(bfsize >> 30));
bf = create_Filter(bflog);
Expand Down
14 changes: 9 additions & 5 deletions tests/sanity_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ static void checkResult32(XXH32_hash_t r1, XXH32_hash_t r2, const char* testName
return;
}

XSUM_log("\rError: %s #%zd, line #%zd: Sanity check failed!\n", testName, testNb, lineNb);
XSUM_log("\rError: %s #%u, line #%u: Sanity check failed!\n",
testName, (unsigned)testNb, (unsigned)lineNb);
XSUM_log("\rGot 0x%08X, expected 0x%08X.\n", (unsigned)r1, (unsigned)r2);

if(abortByError) {
Expand All @@ -124,7 +125,8 @@ static void checkResult64(XXH64_hash_t r1, XXH64_hash_t r2, const char* testName
return;
}

XSUM_log("\rError: %s #%zd, line #%zd: Sanity check failed!\n", testName, testNb, lineNb);
XSUM_log("\rError: %s #%u, line #%u: Sanity check failed!\n",
testName, (unsigned)testNb, (unsigned)lineNb);
XSUM_log("\rGot 0x%08X%08XULL, expected 0x%08X%08XULL.\n",
(unsigned)(r1>>32), (unsigned)r1, (unsigned)(r2>>32), (unsigned)r2);

Expand All @@ -142,7 +144,8 @@ static void checkResult128(XXH128_hash_t r1, XXH128_hash_t r2, const char* testN
return;
}

XSUM_log("\rError: %s #%zd, line #%zd: Sanity check failed!\n", testName, testNb, lineNb);
XSUM_log("\rError: %s #%u, line #%u: Sanity check failed!\n",
testName, (unsigned)testNb, (unsigned)lineNb);
XSUM_log("\rGot { 0x%08X%08XULL, 0x%08X%08XULL }, expected { 0x%08X%08XULL, 0x%08X%08XULL } \n",
(unsigned)(r1.low64>>32), (unsigned)r1.low64, (unsigned)(r1.high64>>32), (unsigned)r1.high64,
(unsigned)(r2.low64>>32), (unsigned)r2.low64, (unsigned)(r2.high64>>32), (unsigned)r2.high64 );
Expand All @@ -161,7 +164,8 @@ static void checkResultTestDataSample(const XSUM_U8* r1, const XSUM_U8* r2, cons
return;
}

XSUM_log("\rError: %s #%zd, line #%zd: Sanity check failed!\n", testName, testNb, lineNb);
XSUM_log("\rError: %s #%u, line #%u: Sanity check failed!\n",
testName, (unsigned)testNb, (unsigned)lineNb);
XSUM_log("\rGot { 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X }, expected { 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X } \n",
r1[0], r1[1], r1[2], r1[3], r1[4],
r2[0], r2[1], r2[2], r2[3], r2[4] );
Expand Down Expand Up @@ -797,7 +801,7 @@ int main(int argc, const char* argv[])

releaseSanityBuffer(sanityBuffer);

XSUM_log("\rOK. (passes %zd tests)\n", testCount);
XSUM_log("\rOK. (passes %u tests)\n", (unsigned)testCount);

return EXIT_SUCCESS;
}