From a68eb730558fb90bc8d9524564d8f9e58f3ccac1 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Mon, 7 Oct 2019 11:20:55 +0200 Subject: Improve ABI backward & forward compatibillity - Padd the compressor config union - 128 bytes aught to be enough for everyone, i.e. future compressors. - Insist that the padding space is initialized to 0. If a field gets added to an existing compressor, it can test for 0 as a sentinel value. - Add a size field to the hook structure, aka "the Microsoft way". - The explanation is in the comment. - Don't make the Microsoft mistake of checking for >=, insist on *exact* size match. Future users will need a fallback if their hooks are rejected. But at least they will be rejected instead of silently not being used. - Add an unsupported flag check to the dir tree reader. - Add a basic abi unit test that, for now, checks the size of the compressor config struct fields. Signed-off-by: David Oberhollenzer --- tests/Makemodule.am | 6 +++++- tests/abi.c | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/abi.c (limited to 'tests') diff --git a/tests/Makemodule.am b/tests/Makemodule.am index d7f8013..8a2241f 100644 --- a/tests/Makemodule.am +++ b/tests/Makemodule.am @@ -70,6 +70,9 @@ test_str_table_SOURCES = tests/str_table.c test_str_table_LDADD = libutil.la test_str_table_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/tests +test_abi_SOURCES = tests/abi.c +test_abi_LDADD = libsquashfs.la + fstree_fuzz_SOURCES = tests/fstree_fuzz.c fstree_fuzz_LDADD = libfstree.a libutil.la @@ -83,6 +86,7 @@ check_PROGRAMS += test_fstree_from_file test_fstree_init check_PROGRAMS += test_tar_ustar test_tar_pax test_tar_gnu test_tar_sparse_gnu check_PROGRAMS += test_tar_sparse_gnu1 test_tar_sparse_gnu2 check_PROGRAMS += test_tar_xattr_bsd test_tar_xattr_schily test_str_table +check_PROGRAMS += test_abi noinst_PROGRAMS += fstree_fuzz tar_fuzz @@ -92,6 +96,6 @@ TESTS += test_add_by_path test_get_path test_fstree_sort test_fstree_from_file TESTS += test_fstree_init test_tar_ustar test_tar_pax TESTS += test_tar_gnu test_tar_sparse_gnu test_tar_sparse_gnu1 TESTS += test_tar_sparse_gnu2 test_tar_xattr_bsd test_tar_xattr_schily -TESTS += test_str_table +TESTS += test_str_table test_abi EXTRA_DIST += $(top_srcdir)/tests/tar $(top_srcdir)/tests/words.txt diff --git a/tests/abi.c b/tests/abi.c new file mode 100644 index 0000000..1601e0a --- /dev/null +++ b/tests/abi.c @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * abi.c + * + * Copyright (C) 2019 David Oberhollenzer + */ +#include "config.h" + +#include "sqfs/compressor.h" + +#include +#include + +int main(void) +{ + sqfs_compressor_config_t cfg; + + assert(sizeof(cfg.opt.gzip) == sizeof(cfg.opt)); + assert(sizeof(cfg.opt.zstd) == sizeof(cfg.opt)); + assert(sizeof(cfg.opt.lzo) == sizeof(cfg.opt)); + assert(sizeof(cfg.opt.xz) == sizeof(cfg.opt)); + assert(sizeof(cfg.opt.padd0) == sizeof(cfg.opt)); + + return EXIT_SUCCESS; +} -- cgit v1.2.3