From 77111086eb38f6075fd2e8e4da74acc32719be02 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Fri, 23 Sep 2022 17:43:01 -0400 Subject: 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 | 2 ++ build-scripts/test-unsigned-char | 4 ++++ qpdf/CMakeLists.txt | 1 + qpdf/test_char_sign.cc | 11 +++++++++++ 4 files changed, 18 insertions(+) create mode 100644 qpdf/test_char_sign.cc diff --git a/build-scripts/build-linux b/build-scripts/build-linux index 3118a955..ced4bbc8 100755 --- a/build-scripts/build-linux +++ b/build-scripts/build-linux @@ -8,6 +8,8 @@ cmake -S . -B build -DCI_MODE=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DREQUIRE_CRYPTO_OPENSSL=1 -DREQUIRE_CRYPTO_GNUTLS=1 cmake --build build -j$(nproc) -- -k cd build +# Make sure char is signed by default -- see also test-unsigned-char +./qpdf/test_char_sign | grep 'char is signed' # libtests automatically runs with all crypto providers. env QPDF_TEST_COMPARE_IMAGES=1 ctest --verbose # Run just qpdf tests with remaining crypto providers. diff --git a/build-scripts/test-unsigned-char b/build-scripts/test-unsigned-char index 840b517d..1f4c68d8 100755 --- a/build-scripts/test-unsigned-char +++ b/build-scripts/test-unsigned-char @@ -15,4 +15,8 @@ env CFLAGS="-funsigned-char" \ -DENABLE_QTC=1 cmake --build build -j$(nproc) -- -k cd build +# Make sure char is unsigned by default. ./build-linux verifies that +# that build has char signed by default. That way we can be sure we +# are testing both ways. +./qpdf/test_char_sign | grep 'char is unsigned' ctest --verbose diff --git a/qpdf/CMakeLists.txt b/qpdf/CMakeLists.txt index 69eb0058..d089957b 100644 --- a/qpdf/CMakeLists.txt +++ b/qpdf/CMakeLists.txt @@ -3,6 +3,7 @@ set(MAIN_CXX_PROGRAMS fix-qdf pdf_from_scratch sizes + test_char_sign test_driver test_large_file test_many_nulls diff --git a/qpdf/test_char_sign.cc b/qpdf/test_char_sign.cc new file mode 100644 index 00000000..caaa7527 --- /dev/null +++ b/qpdf/test_char_sign.cc @@ -0,0 +1,11 @@ +#include +int main() +{ + char ch = '\xf7'; + if (ch < 0) { + printf("char is signed\n"); + } else { + printf("char is unsigned\n"); + } + return 0; +} -- cgit v1.2.3-70-g09d2