|
| 1 | +name: UndefinedBehaviorSanitizer Build and Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ 'master', 'main', 'release/**' ] |
| 6 | + pull_request: |
| 7 | + branches: [ 'master' ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + # Run UBSan build and test on Linux only for undefined behavior detection |
| 11 | + ubsan: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + jdk_version: [ '21' ] |
| 16 | + wolfssl_configure: [ '--enable-jni --enable-debug' ] |
| 17 | + name: UBSan (ubuntu-latest Zulu JDK ${{ matrix.jdk_version }}) |
| 18 | + |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Cache JUnit dependencies |
| 23 | + uses: actions/cache@v4 |
| 24 | + id: cache-junit |
| 25 | + with: |
| 26 | + path: junit |
| 27 | + key: junit-jars-v1 |
| 28 | + |
| 29 | + - name: Download junit-4.13.2.jar |
| 30 | + if: steps.cache-junit.outputs.cache-hit != 'true' |
| 31 | + run: wget --directory-prefix=$GITHUB_WORKSPACE/junit https://repo1.maven.org/maven2/junit/junit/4.13.2/junit-4.13.2.jar |
| 32 | + - name: Download hamcrest-all-1.3.jar |
| 33 | + if: steps.cache-junit.outputs.cache-hit != 'true' |
| 34 | + run: wget --directory-prefix=$GITHUB_WORKSPACE/junit https://repo1.maven.org/maven2/org/hamcrest/hamcrest-all/1.3/hamcrest-all-1.3.jar |
| 35 | + |
| 36 | + - name: Build native wolfSSL with UndefinedBehaviorSanitizer |
| 37 | + uses: wolfSSL/actions-build-autotools-project@v1 |
| 38 | + with: |
| 39 | + repository: wolfSSL/wolfssl |
| 40 | + ref: master |
| 41 | + path: wolfssl |
| 42 | + configure: ${{ matrix.wolfssl_configure }} CFLAGS="-fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer" LDFLAGS="-fsanitize=undefined" |
| 43 | + check: false |
| 44 | + install: true |
| 45 | + |
| 46 | + - name: Setup java |
| 47 | + uses: actions/setup-java@v4 |
| 48 | + with: |
| 49 | + distribution: 'zulu' |
| 50 | + java-version: ${{ matrix.jdk_version }} |
| 51 | + |
| 52 | + - name: Set environment variables |
| 53 | + run: | |
| 54 | + echo "JUNIT_HOME=$GITHUB_WORKSPACE/junit" >> "$GITHUB_ENV" |
| 55 | + echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GITHUB_WORKSPACE/build-dir/lib" >> "$GITHUB_ENV" |
| 56 | + echo "UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1" >> "$GITHUB_ENV" |
| 57 | +
|
| 58 | + - name: Build JNI library with UndefinedBehaviorSanitizer |
| 59 | + run: CFLAGS="-fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer -g" LDFLAGS="-fsanitize=undefined" ./java.sh $GITHUB_WORKSPACE/build-dir |
| 60 | + |
| 61 | + - name: Build JAR (ant) |
| 62 | + run: ant |
| 63 | + |
| 64 | + - name: Run Java tests with UndefinedBehaviorSanitizer (ant test) |
| 65 | + run: ant test |
| 66 | + |
| 67 | + - name: Show logs on failure |
| 68 | + if: failure() || cancelled() |
| 69 | + run: | |
| 70 | + cat build/reports/*.txt |
0 commit comments