diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e80a736480dd1e8f7ae7c6d43bf3c36400856f84..c8795ecb963e0b441886a1b625bd9b6e081cb72b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,7 @@ after_script: - ./cicd_testing/do-clean.sh - ./cicd_testing/do-build.sh - ./cicd_testing/xform-ls.sh - - ./cicd_testing/starstest.sh + - ./cicd_testing/starstest2.sh # per os items test-ubuntu18: @@ -24,15 +24,15 @@ test-ubuntu18: tags: - ubuntu18 -#test-ubuntu20: -# <<: *test -# tags: -# - ubuntu20 +test-ubuntu20: + <<: *test + tags: + - ubuntu20 -#test-ubuntu22: -# <<: *test -# tags: -# - ubuntu22 +test-ubuntu22: + <<: *test + tags: + - ubuntu22 test-coss9: <<: *test diff --git a/cicd_testing/starstest2.sh b/cicd_testing/starstest2.sh new file mode 100755 index 0000000000000000000000000000000000000000..297e355054e9b6d842b7f1a9d85f5cf82131cbc3 --- /dev/null +++ b/cicd_testing/starstest2.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# Usage: + +function validate +{ + if ! grep "FROMIB COMPLETE 8 SWITCHTABLE" $1.STARSxrefs > /dev/null; then + echo "Failed to find COMPLETE 8 SWITCHTABLE xref annotation" + exit 3 + fi + if ! grep "FROMIB COMPLETE 1 RETURNTARGET" $1.STARSxrefs > /dev/null; then + echo "Failed to find any COMPLETE RETURNTARGET xref annotations" + exit 2 + fi + if ! tail $1.infoannot | grep "SUCCESS ANALYSISCOMPLETED" > /dev/null; then + echo "Failed to find SUCCESS ANALYSISCOMPLETED annotation" + exit 1 + fi + + echo "STARS success" + return 0 +} + +function test() +{ + . $SMPSA_HOME/SMP-fullanalyze64-ida7.sh $1 + validate $1 +} + +# Pass in optimization level string, e.g. O0, Og, or O3 +function build() +{ + rm -f starstest2_$1.exe + gcc -m64 -$1 -o starstest2_$1.exe $SMPSA_HOME/tests/starstest2.c +} + +# Pass in optimization level string, e.g. O0, Og, or O3 +function build_and_test() +{ + build $1 + test starstest2_$1.exe +} + +function main() +{ + set -e + set -x + + cd $CICD_MODULE_WORK_DIR/cicd_stars_umbrella + export IDAROOT=$CICD_MODULE_WORK_DIR/idapro71 + export IDASDK=$CICD_MODULE_WORK_DIR/idapro71_sdk + + source set_env_vars + mkdir -p /tmp/stars_test + cd /tmp/stars_test + + # Build and test each of the optimization levels -O0, -Og, and -O3. + if build_and_test O0 ; then + if build_and_test Og ; then + build_and_test O3 + fi + fi + + return 0 + +} + +main "$@" diff --git a/tests/starstest2.c b/tests/starstest2.c new file mode 100644 index 0000000000000000000000000000000000000000..d8b7c812ac9086120a0d37b5d5e1bf221441b1b0 --- /dev/null +++ b/tests/starstest2.c @@ -0,0 +1,108 @@ +#include <stdlib.h> +#include <stdio.h> + +#define SMP_BUFFER_SIZE 8 + +static int buffer[SMP_BUFFER_SIZE]; + +unsigned int f0(unsigned int foo) { + return 3 + buffer[foo]; +} + +unsigned int f1(unsigned int foo) { + return 7 + buffer[foo]; +} + +unsigned int f2(unsigned int foo) { + return 5 + buffer[foo]; +} + +unsigned int f3(unsigned int foo) { + return 6 + buffer[foo]; +} + +unsigned int f4(unsigned int foo) { + return 12 + buffer[foo]; +} + +unsigned int f5(unsigned int foo) { + return 8 + buffer[foo]; +} + +unsigned int f6(unsigned int foo) { + return 2 + buffer[foo]; +} + +unsigned int f7(unsigned int foo) { + return 9 + buffer[foo]; +} + +unsigned int GetIndex(void) { + unsigned int randindex = rand() % SMP_BUFFER_SIZE; + return randindex; +} + +void RandomElementSwap(const unsigned int index2) { + unsigned int index1 = rand() % SMP_BUFFER_SIZE; + int temp = buffer[index1]; + buffer[index1] = buffer[index2]; + buffer[index2] = temp; + return; +} + +unsigned int GetValueBasedIndex(void) { + unsigned int value = 0; + unsigned int randindex = rand() % SMP_BUFFER_SIZE; + switch (randindex) { + case 0: + value = f0(17); + break; + case 1: + value = f1(12); + break; + case 2: + value = f2(4); + break; + case 3: + value = f3(1); + break; + case 4: + value = f4(18); + break; + case 5: + value = f5(7); + break; + case 6: + value = f6(3); + break; + case 7: + value = f7(19); + break; + default: + value = f0(0); + break; + } + + return (value % SMP_BUFFER_SIZE); +} /* end of GetValueBasedIndex() */ + +int main() { + unsigned int index, randindex; + srand(17); /* seed the generator */ + + for (index = 0; index < SMP_BUFFER_SIZE; ++index) { + buffer[index] = rand(); + } + + randindex = GetValueBasedIndex(); + RandomElementSwap(randindex); + + printf("Here are %u random integers:\n", SMP_BUFFER_SIZE); + + for (index = 0; index < SMP_BUFFER_SIZE; ++index) { + randindex = rand() % SMP_BUFFER_SIZE; + printf("%d\n", buffer[randindex]); + } + + return 0; +}