From 181603ce8296047103ffc5be368597c5982b5464 Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Fri, 27 Sep 2024 09:30:02 +0100 Subject: [PATCH] Add a bunch more tests to workflows --- .github/workflows/distcheck.yml | 25 ++++++++++++++++ .github/workflows/docs.yml | 25 ++++++++++++++++ .github/workflows/scanbuild.yml | 30 +++++++++++++++++++ .github/workflows/usan.yml | 53 +++++++++++++++++++++++++++++++++ src/sha256_i.h | 14 ++++----- tests/copy.c | 6 ++-- 6 files changed, 143 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/distcheck.yml create mode 100644 .github/workflows/docs.yml create mode 100644 .github/workflows/scanbuild.yml create mode 100644 .github/workflows/usan.yml diff --git a/.github/workflows/distcheck.yml b/.github/workflows/distcheck.yml new file mode 100644 index 0000000..7d28597 --- /dev/null +++ b/.github/workflows/distcheck.yml @@ -0,0 +1,25 @@ +name: Distcheck + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Install deps + run: | + sudo apt-get update + sudo apt-get install -y libcurl4-openssl-dev + - name: Build libmarias3 + run: | + autoreconf -fi + ./configure --enable-debug=yes + - name: Test + run: + make distcheck diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..24db79d --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,25 @@ +name: Docs + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Install deps + run: | + sudo apt-get update + sudo apt-get install -y libcurl4-openssl-dev python3-sphinx + - name: Build libmarias3 + run: | + autoreconf -fi + ./configure + - name: Build Docs + run: + make html diff --git a/.github/workflows/scanbuild.yml b/.github/workflows/scanbuild.yml new file mode 100644 index 0000000..03dfa1b --- /dev/null +++ b/.github/workflows/scanbuild.yml @@ -0,0 +1,30 @@ +name: Scanbuild test + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + # Ubuntu latest scan-build has issues 2024-09. This is a documentated hack + # to run Fedora instead + runs-on: ubuntu-latest + container: + image: fedora:latest + env: + CC: clang + + steps: + - uses: actions/checkout@v4 + - name: Install deps + run: | + sudo dnf install -y libcurl-devel clang-analyzer autoconf automake libtool + - name: Build libmarias3 + run: | + autoreconf -fi + ./configure --enable-debug=yes + - name: Scanbuild + run: + scan-build --use-cc=clang --use-c++=clang++ --status-bugs make diff --git a/.github/workflows/usan.yml b/.github/workflows/usan.yml new file mode 100644 index 0000000..e09e408 --- /dev/null +++ b/.github/workflows/usan.yml @@ -0,0 +1,53 @@ +name: USAN test + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + runs-on: ubuntu-latest + services: + minio: + # fixme: let's not depend on external unofficial image + image: lazybit/minio + ports: + - 9000:9000 + env: + MINIO_ROOT_USER: accesskey + MINIO_ROOT_PASSWORD: password + options: --name=minio --health-cmd "curl http://localhost:9000/minio/health/live" + + env: + S3KEY: accesskey + S3SECRET: password + S3REGION: "" + S3BUCKET: s3-test + S3HOST: 127.0.0.1 + S3PORT: 9000 + S3USEHTTP: 1 + CC: clang + CFLAGS: "-fsanitize=undefined -fsanitize=nullability" + + steps: + - uses: actions/checkout@v4 + - name: Create bucket + run: | + wget https://dl.min.io/client/mc/release/linux-amd64/mc + chmod +x ./mc + ./mc alias set minio http://127.0.0.1:9000 accesskey password + ./mc mb --ignore-existing minio/s3-test + - name: Install deps + run: | + sudo apt-get update + sudo apt-get install -y libcurl4-openssl-dev + - name: Build libmarias3 + run: | + autoreconf -fi + ./configure --enable-debug=yes + make + - name: Test + run: + make check diff --git a/src/sha256_i.h b/src/sha256_i.h index 9b8aa2b..5779014 100644 --- a/src/sha256_i.h +++ b/src/sha256_i.h @@ -38,13 +38,13 @@ int sha256_vector(size_t num_elem, const uint8_t *addr[], const size_t *len, static inline void WPA_PUT_BE64(uint8_t *a, uint64_t val) { - a[0] = val >> 56; - a[1] = val >> 48; - a[2] = val >> 40; - a[3] = val >> 32; - a[4] = val >> 24; - a[5] = val >> 16; - a[6] = val >> 8; + a[0] = (val >> 56) & 0xff; + a[1] = (val >> 48) & 0xff; + a[2] = (val >> 40) & 0xff; + a[3] = (val >> 32) & 0xff; + a[4] = (val >> 24) & 0xff; + a[5] = (val >> 16) & 0xff; + a[6] = (val >> 8) & 0xff; a[7] = val & 0xff; } diff --git a/tests/copy.c b/tests/copy.c index 64e2caf..9855671 100644 --- a/tests/copy.c +++ b/tests/copy.c @@ -170,9 +170,9 @@ int main(int argc, char *argv[]) res = ms3_delete(ms3, s3bucket, "test/moved.txt"); ASSERT_EQ_(res, 0, "Result: %u", res); - res = ms3_delete(ms3, s3bucket, "test/copied.txt"); - res = ms3_delete(ms3, s3bucket, "test/copy_###_test.txt"); - res = ms3_delete(ms3, s3bucket, "test/copied###.txt"); + ms3_delete(ms3, s3bucket, "test/copied.txt"); + ms3_delete(ms3, s3bucket, "test/copy_###_test.txt"); + ms3_delete(ms3, s3bucket, "test/copied###.txt"); ms3_free(data); ms3_deinit(ms3);