Able to test combine script; minor tidy

This commit is contained in:
Carl Woffenden 2019-08-26 07:48:57 +02:00
parent d760e35ebc
commit ea8f6d2a07
4 changed files with 23 additions and 16 deletions

View File

@ -3,9 +3,9 @@ sh_test(
visibility=['PUBLIC'],
test='combine.sh',
args=[
'-r', '../../lib',
'-r', '../../lib/common',
'-r', '../../lib/decompress',
'-o', 'zstddeclib.c',
'zstddeclib-in.c']
'-r', 'lib',
'-r', 'lib/common',
'-r', 'lib/decompress',
'-o', 'contrib/declib/zstddeclib.c',
'contrib/declib/zstddeclib-in.c']
)

View File

@ -45,11 +45,15 @@ function write_line {
function add_file {
# Match the path
local file=
for root in $ROOTS; do
if test -f "$root/$1"; then
file="$root/$1"
fi
done
if [ -f "$1" ]; then
file="$1"
else
for root in $ROOTS; do
if test -f "$root/$1"; then
file="$root/$1"
fi
done
fi
if [ -n "$file" ]; then
# Read the file
local line

View File

@ -1,5 +1,7 @@
cxx_test(
# Note: we need to undef ZSTD_LEGACY_SUPPORT since Buck defines it elsewhere
cxx_binary(
name='simple',
srcs=['simple.c'],
preprocessor_flags=['-UZSTD_LEGACY_SUPPORT'],
deps=['//contrib/declib:combine']
)

View File

@ -2,10 +2,11 @@
* \file simple.c
* Simple standalone example of using the single-file \c zstddeclib.
*/
#include "../zstddeclib.c"
#include <stdio.h>
#include <string.h>
#include "stdio.h"
#include "string.h"
#include "../zstddeclib.c"
//************************* Test Data (DXT texture) **************************/
@ -3387,8 +3388,8 @@ size_t ZSTD_decompress(void* dst, size_t dstLen, const void* src, size_t srcLen)
int main() {
size_t size = ZSTD_decompress(dstDxt1, sizeof dstDxt1, srcZstd, sizeof srcZstd);
int compare = memcmp(rawDxt1, dstDxt1, sizeof dstDxt1);
printf("Decompressed size: %ld (expected %ld)\n", size, sizeof dstDxt1);
printf("Byte comparison: %s\n", (compare) ? "failed" : "succeeded");
printf("Decompressed size: %s\n", (size == sizeof dstDxt1) ? "OK" : "FAILED");
printf("Byte comparison: %s\n", (compare == 0) ? "OK" : "FAILED");
if (size == sizeof dstDxt1 && compare == 0) {
return EXIT_SUCCESS;
}