Commit 77111086eb38f6075fd2e8e4da74acc32719be02

Authored by Jay Berkenbilt
1 parent a085479a

Add code to CI to verify signed/unsigned char

Make sure that our attempt to test both signed and unsigned char is
actually right.
build-scripts/build-linux
... ... @@ -8,6 +8,8 @@ cmake -S . -B build -DCI_MODE=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
8 8 -DREQUIRE_CRYPTO_OPENSSL=1 -DREQUIRE_CRYPTO_GNUTLS=1
9 9 cmake --build build -j$(nproc) -- -k
10 10 cd build
  11 +# Make sure char is signed by default -- see also test-unsigned-char
  12 +./qpdf/test_char_sign | grep 'char is signed'
11 13 # libtests automatically runs with all crypto providers.
12 14 env QPDF_TEST_COMPARE_IMAGES=1 ctest --verbose
13 15 # Run just qpdf tests with remaining crypto providers.
... ...
build-scripts/test-unsigned-char
... ... @@ -15,4 +15,8 @@ env CFLAGS="-funsigned-char" \
15 15 -DENABLE_QTC=1
16 16 cmake --build build -j$(nproc) -- -k
17 17 cd build
  18 +# Make sure char is unsigned by default. ./build-linux verifies that
  19 +# that build has char signed by default. That way we can be sure we
  20 +# are testing both ways.
  21 +./qpdf/test_char_sign | grep 'char is unsigned'
18 22 ctest --verbose
... ...
qpdf/CMakeLists.txt
... ... @@ -3,6 +3,7 @@ set(MAIN_CXX_PROGRAMS
3 3 fix-qdf
4 4 pdf_from_scratch
5 5 sizes
  6 + test_char_sign
6 7 test_driver
7 8 test_large_file
8 9 test_many_nulls
... ...
qpdf/test_char_sign.cc 0 → 100644
  1 +#include <cstdio>
  2 +int main()
  3 +{
  4 + char ch = '\xf7';
  5 + if (ch < 0) {
  6 + printf("char is signed\n");
  7 + } else {
  8 + printf("char is unsigned\n");
  9 + }
  10 + return 0;
  11 +}
... ...