summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2022-07-12 16:59:54 (GMT)
committerYann Collet <yann.collet.73@gmail.com>2022-07-12 17:37:46 (GMT)
commitd64575391967af5fbbc3d991ecb9035fb3460531 (patch)
tree128849c496f7780a60a098569995e50e12eb51c5
parent3e2426b198293d1e64de949c40fe0ddc2fb9befb (diff)
downloadlz4-d64575391967af5fbbc3d991ecb9035fb3460531.zip
lz4-d64575391967af5fbbc3d991ecb9035fb3460531.tar.gz
lz4-d64575391967af5fbbc3d991ecb9035fb3460531.tar.bz2
generalize across all 3 ABI architectures
-rw-r--r--tests/abiTest.c1
-rw-r--r--tests/test-lz4-abi.py154
2 files changed, 85 insertions, 70 deletions
diff --git a/tests/abiTest.c b/tests/abiTest.c
index 423dc1f..91e4e79 100644
--- a/tests/abiTest.c
+++ b/tests/abiTest.c
@@ -77,7 +77,6 @@ static void roundTripTest(void* resultBuff, size_t resultBuffCapacity,
{
int const acceleration = 1;
// Note : can't use LZ4_initStream(), because it's only present since v1.9.0
- MSG("Initializing LZ4_cState, of size %zu bytes \n", sizeof(LZ4_cState));
memset(&LZ4_cState, 0, sizeof(LZ4_cState));
{ int const cSize = LZ4_compress_fast_continue(&LZ4_cState, (const char*)srcBuff, (char*)compressedBuff, (int)srcSize, (int)compressedBuffCapacity, acceleration);
CONTROL_MSG(cSize == 0, "Compression error !");
diff --git a/tests/test-lz4-abi.py b/tests/test-lz4-abi.py
index e194ce2..0c8fd05 100644
--- a/tests/test-lz4-abi.py
+++ b/tests/test-lz4-abi.py
@@ -26,8 +26,6 @@ head = 'v999'
def proc(cmd_args, pipe=True, env=False):
if env == False:
env = os.environ.copy()
- # we want the address sanitizer for abi tests
- env["MOREFLAGS"] = "-fsanitize=address"
if pipe:
s = subprocess.Popen(cmd_args,
stdout=subprocess.PIPE,
@@ -42,6 +40,10 @@ def proc(cmd_args, pipe=True, env=False):
return r
def make(args, pipe=True, env=False):
+ if env == False:
+ env = os.environ.copy()
+ # we want the address sanitizer for abi tests
+ env["MOREFLAGS"] = "-fsanitize=address"
return proc([make_cmd] + ['-j'] + ['V=1'] + args, pipe, env)
def git(args, pipe=True):
@@ -78,77 +80,91 @@ if __name__ == '__main__':
tags = [x for x in tags if (x >= 'v1.7.5')]
print(tags)
- # Build all versions of liblz4
- # note : naming scheme only works on Linux
- for tag in tags:
- print('building library ', tag)
- os.chdir(base_dir)
-# if not os.path.isfile(dst_liblz4) or tag == head:
- if tag != head:
- r_dir = '{}/{}'.format(tmp_dir, tag) # /path/to/lz4/test/lz4test/<TAG>
- #print('r_dir = ', r_dir) # for debug
- os.makedirs(r_dir, exist_ok=True)
- os.chdir(clone_dir)
- git(['--work-tree=' + r_dir, 'checkout', tag, '--', '.'])
- os.chdir(r_dir + '/lib') # /path/to/lz4/lz4test/<TAG>/lib
- else:
- # print('lib_dir = {}', lib_dir) # for debug
- os.chdir(lib_dir) # for debug
- make(['clean'])
- make(['liblz4'])
-
- print(' ')
- print('******************************')
- print('Round trip expecting current ABI but linking to older Dynamic Library version')
- print('******************************')
- os.chdir(test_dir)
- # Start with matching version : should be no problem
- build_env = os.environ.copy()
- build_env["LDFLAGS"] = "-L../lib"
- build_env["LDLIBS"] = "-llz4"
- # we use asan to detect any out-of-bound read or write
- build_env["MOREFLAGS"] = "-fsanitize=address"
- if os.path.isfile('abiTest'):
- os.remove('abiTest')
- make(['abiTest'], env=build_env)
- proc(['./abiTest'] + ['README.md'])
-
- for tag in tags:
- print('linking to lib tag = ', tag)
- run_env = os.environ.copy()
- run_env["LD_LIBRARY_PATH"] = 'abiTests/{}/lib'.format(tag)
- # check we are linking to the right library version at run time
- proc(['./check_liblz4_version.sh'] + ['./abiTest'], pipe=False, env=run_env)
- # now run with mismatched library version
- proc(['./abiTest'] + test_dat_src, pipe=False, env=run_env)
-
- print(' ')
- print('******************************')
- print('Round trip using current Dynamic Library expecting older ABI version')
- print('******************************')
-
- for tag in tags:
+ # loop across architectures
+ for march in ['-m64', '-m32', '-mx32']:
+ print(' ')
+ print('=====================================')
+ print('Testing architecture ' + march);
+ print('=====================================')
+
+ # Build all versions of liblz4
+ # note : naming scheme only works on Linux
+ for tag in tags:
+ print('building library ', tag)
+ os.chdir(base_dir)
+ # if not os.path.isfile(dst_liblz4) or tag == head:
+ if tag != head:
+ r_dir = '{}/{}'.format(tmp_dir, tag) # /path/to/lz4/test/lz4test/<TAG>
+ #print('r_dir = ', r_dir) # for debug
+ os.makedirs(r_dir, exist_ok=True)
+ os.chdir(clone_dir)
+ git(['--work-tree=' + r_dir, 'checkout', tag, '--', '.'])
+ os.chdir(r_dir + '/lib') # /path/to/lz4/lz4test/<TAG>/lib
+ else:
+ # print('lib_dir = {}', lib_dir) # for debug
+ os.chdir(lib_dir)
+ make(['clean'])
+ build_env = os.environ.copy()
+ build_env["CFLAGS"] = march
+ build_env["MOREFLAGS"] = "-fsanitize=address"
+ make(['liblz4'], env=build_env)
+
print(' ')
- print('building using older lib ', tag)
+ print('******************************')
+ print('Round trip expecting current ABI but linking to older Dynamic Library version')
+ print('******************************')
+ os.chdir(test_dir)
+ # Start with matching version : should be no problem
build_env = os.environ.copy()
- if tag != head:
- build_env["CPPFLAGS"] = '-IabiTests/{}/lib'.format(tag)
- build_env["LDFLAGS"] = '-LabiTests/{}/lib'.format(tag)
- else:
- build_env["CPPFLAGS"] = '-I../lib'
- build_env["LDFLAGS"] = '-L../lib'
+ build_env["CFLAGS"] = march
+ build_env["LDFLAGS"] = "-L../lib"
build_env["LDLIBS"] = "-llz4"
+ # we use asan to detect any out-of-bound read or write
build_env["MOREFLAGS"] = "-fsanitize=address"
- os.remove('abiTest')
- make(['abiTest'], pipe=False, env=build_env)
-
- print('run with CURRENT library version (head)')
- run_env = os.environ.copy()
- run_env["LD_LIBRARY_PATH"] = '../lib'
- # check we are linking to the right library version at run time
- proc(['./check_liblz4_version.sh'] + ['./abiTest'], pipe=False, env=run_env)
- # now run with mismatched library version
- proc(['./abiTest'] + test_dat_src, pipe=False, env=run_env)
+ if os.path.isfile('abiTest'):
+ os.remove('abiTest')
+ make(['abiTest'], env=build_env, pipe=False)
+
+ for tag in tags:
+ print('linking to lib tag = ', tag)
+ run_env = os.environ.copy()
+ if tag == head:
+ run_env["LD_LIBRARY_PATH"] = '../lib'
+ else:
+ run_env["LD_LIBRARY_PATH"] = 'abiTests/{}/lib'.format(tag)
+ # check we are linking to the right library version at run time
+ proc(['./check_liblz4_version.sh'] + ['./abiTest'], pipe=False, env=run_env)
+ # now run with mismatched library version
+ proc(['./abiTest'] + test_dat_src, pipe=False, env=run_env)
+
+ print(' ')
+ print('******************************')
+ print('Round trip using current Dynamic Library expecting older ABI version')
+ print('******************************')
+
+ for tag in tags:
+ print(' ')
+ print('building using older lib ', tag)
+ build_env = os.environ.copy()
+ if tag != head:
+ build_env["CPPFLAGS"] = '-IabiTests/{}/lib'.format(tag)
+ build_env["LDFLAGS"] = '-LabiTests/{}/lib'.format(tag)
+ else:
+ build_env["CPPFLAGS"] = '-I../lib'
+ build_env["LDFLAGS"] = '-L../lib'
+ build_env["LDLIBS"] = "-llz4"
+ build_env["CFLAGS"] = march
+ build_env["MOREFLAGS"] = "-fsanitize=address"
+ os.remove('abiTest')
+ make(['abiTest'], pipe=False, env=build_env)
+
+ print('run with CURRENT library version (head)')
+ run_env = os.environ.copy()
+ run_env["LD_LIBRARY_PATH"] = '../lib'
+ # check we are linking to the right library version at run time
+ proc(['./check_liblz4_version.sh'] + ['./abiTest'], pipe=False, env=run_env)
+ # now run with mismatched library version
+ proc(['./abiTest'] + test_dat_src, pipe=False, env=run_env)
if error_code != 0: