-
Notifications
You must be signed in to change notification settings - Fork 0
Add automated testing workflow with GTest integration #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a2c12ff
eb412e6
0cd0c35
cf293c4
b891cca
294af83
3603e19
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,8 @@ on: | |
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,60 @@ | ||||||
| name: Run Tests | ||||||
|
|
||||||
| on: | ||||||
| push: | ||||||
| branches: [ main ] | ||||||
| pull_request: | ||||||
| branches: [ main ] | ||||||
|
|
||||||
| jobs: | ||||||
| test: | ||||||
| runs-on: ubuntu-latest | ||||||
| permissions: | ||||||
| contents: read | ||||||
| checks: write | ||||||
|
|
||||||
| steps: | ||||||
| - name: Checkout code | ||||||
| uses: actions/checkout@v4 | ||||||
|
|
||||||
| - name: Install Conan | ||||||
| uses: conan-io/setup-conan@v1 | ||||||
|
|
||||||
| - name: Create default Conan profile | ||||||
| run: conan profile detect --force | ||||||
|
|
||||||
| - name: Create build directory | ||||||
| run: mkdir -p src/build | ||||||
|
|
||||||
| - name: Install dependencies | ||||||
| run: conan install src --output-folder=src/build --build=missing | ||||||
|
|
||||||
| - name: Configure CMake | ||||||
| working-directory: src | ||||||
| run: cmake --preset conan-release | ||||||
|
|
||||||
| - name: Build | ||||||
| working-directory: src | ||||||
| run: cmake --build --preset conan-release | ||||||
|
|
||||||
| - name: Run unit tests | ||||||
| working-directory: src | ||||||
| run: | | ||||||
| echo "Running SHA implementation tests..." | ||||||
| ./run_all_ut.sh Release | ||||||
| # Also generate XML output for test reporting | ||||||
| ./build/Release/ut_sha_functions --gtest_output=xml:test-results.xml | ||||||
| continue-on-error: false | ||||||
|
||||||
| continue-on-error: false |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Test Summary step always shows success even if tests fail. Since the "Run unit tests" step has continue-on-error: false, failures will be caught, but this message is misleading. Consider making it conditional or reflecting the actual test status using GitHub Actions expressions like if: success() instead of if: always().
| if: always() | |
| if: success() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| # Italian: Implementazione Secure Hash Algorithm (SHA) | ||
|
|
||
| [](https://github.com/AndreaCicca/SHA-implementation/actions/workflows/compilation.yaml) | ||
| [](https://github.com/AndreaCicca/SHA-implementation/actions/workflows/test.yaml) | ||
|
|
||
| Corso di Crittografia presso Unipr. | ||
|
|
||
|
|
@@ -42,3 +43,32 @@ cmake --build build | |
|
|
||
| > [!NOTE] | ||
| > Per non copia e incollare i singoli comandi si può usare lo script src/compile.sh | ||
|
|
||
| ## Esecuzione dei test | ||
|
|
||
| Dopo aver compilato il progetto, è possibile eseguire i test unitari: | ||
|
|
||
| ### Eseguire tutti i test | ||
|
|
||
| ```bash | ||
| cd src && ./run_all_ut.sh | ||
| ``` | ||
|
|
||
| ### Eseguire i test manualmente | ||
|
|
||
| ```bash | ||
| cd src && ./build/Release/ut_sha_functions | ||
| ``` | ||
|
|
||
| ### Eseguire i test con output XML (per CI/CD) | ||
|
|
||
| ```bash | ||
| cd src && ./build/Release/ut_sha_functions --gtest_output=xml:test-results.xml | ||
| ``` | ||
|
|
||
| I test verificano la correttezza dell'implementazione SHA-1 e SHA-256 confrontandola con la libreria OpenSSL, includendo: | ||
| - Test con stringhe vuote, corte, lunghe e molto lunghe | ||
| - Test con caratteri speciali e non-ASCII | ||
| - Test di determinismo | ||
| - Test dell'effetto valanga (avalanche effect) | ||
| - Test di performance | ||
|
Comment on lines
+69
to
+74
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,9 +5,32 @@ set -e | |||||||
| # Nella cartella ./build avviare tutti gli eseguibili che iniziano con ut_ | ||||||||
|
||||||||
| # Nella cartella ./build avviare tutti gli eseguibili che iniziano con ut_ | |
| # Script per eseguire tutti gli eseguibili di test che iniziano con ut_ | |
| # Cerca nelle cartelle di build (es. ./build/<BUILD_TYPE> e ./build) usando un BUILD_TYPE opzionale (default: Release) |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script searches for test executables matching the pattern ut_*, but there's no validation that the matched files are actually executable files (not directories). The check if [ -x "$file" ] helps, but the glob pattern "$location"/ut_* could match a non-existent file if no files match, causing the script to try to execute a literal string like "build/Release/ut_*". Consider adding a check if [ -f "$file" ] before the executable check.
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message "All tests completed successfully!" is misleading because it will be printed even if tests fail. The script uses set -e which should cause it to exit on test failure, but the message assumes success. Consider making the success message conditional or removing it since the exit code already indicates success.
| echo "All tests completed successfully! ($TESTS_FOUND test suite(s) executed)" | |
| echo "Test execution completed. ($TESTS_FOUND test suite(s) executed)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests are being run twice - once via
run_all_ut.shand again directly with--gtest_output=xml. This means the test suite executes twice on every run, doubling the CI execution time unnecessarily. Consider removing line 44 and modifyingrun_all_ut.shto accept an optional parameter for generating XML output, or just run the test executable directly with the XML flag.