|
| 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: Copy makefile |
| 59 | + run: cp makefile.linux makefile |
| 60 | + |
| 61 | + - name: Build JNI library with UndefinedBehaviorSanitizer |
| 62 | + run: CFLAGS="-fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer -g" LDFLAGS="-fsanitize=undefined" PREFIX=$GITHUB_WORKSPACE/build-dir make |
| 63 | + |
| 64 | + # ant build-jni-debug |
| 65 | + - name: Build jni-debug JAR (ant build-jni-debug) |
| 66 | + run: ant build-jni-debug |
| 67 | + - name: Run Java tests (ant test) |
| 68 | + run: ant test |
| 69 | + - name: Clean JAR |
| 70 | + run: ant clean |
| 71 | + |
| 72 | + # ant build-jni-release |
| 73 | + - name: Build jni-release JAR (ant build-jni-release) |
| 74 | + run: ant build-jni-release |
| 75 | + - name: Run Java tests (ant test) |
| 76 | + run: ant test |
| 77 | + - name: Clean JAR |
| 78 | + run: ant clean |
| 79 | + |
| 80 | + # ant build-jce-debug |
| 81 | + - name: Build jce-debug JAR (ant build-jce-debug) |
| 82 | + run: ant build-jce-debug |
| 83 | + - name: Run Java tests (ant test) |
| 84 | + run: ant test |
| 85 | + - name: Clean JAR |
| 86 | + run: ant clean |
| 87 | + |
| 88 | + # ant build-jce-release |
| 89 | + - name: Build jce-release JAR (ant build-jce-release) |
| 90 | + run: ant build-jce-release |
| 91 | + - name: Run Java tests (ant test) |
| 92 | + run: ant test |
| 93 | + - name: Clean JAR |
| 94 | + run: ant clean |
| 95 | + |
| 96 | + - name: Show logs on failure |
| 97 | + if: failure() || cancelled() |
| 98 | + run: | |
| 99 | + cat build/reports/*.txt 2>/dev/null || true |
0 commit comments