diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-10-07 11:20:55 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-10-07 12:22:05 +0200 |
commit | a68eb730558fb90bc8d9524564d8f9e58f3ccac1 (patch) | |
tree | de7a678b28786ec2e47e4956d8cdb0f4466f3d5c /tests/abi.c | |
parent | c7fdb2b305ed8b4deb67bfc6ef3257e7e6773397 (diff) |
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 <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tests/abi.c')
-rw-r--r-- | tests/abi.c | 25 |
1 files changed, 25 insertions, 0 deletions
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 <goliath@infraroot.at> + */ +#include "config.h" + +#include "sqfs/compressor.h" + +#include <assert.h> +#include <stdlib.h> + +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; +} |