Skip to content
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

Automated gtest formatting checks #3370

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,19 @@ pipeline {
buildHipClangJobAndReboot(setup_cmd: "", build_cmd: "", execute_cmd: execute_cmd, needs_gpu:false, needs_reboot:false)
}
}
stage('Check GTest Format') {
agent{ label rocmnode("nogpu") }
when {
changeset "test/gtest/**"
}

environment{
execute_cmd = 'test/utils/check_gtests.sh'
}
steps{
buildHipClangJobAndReboot(setup_cmd: "", build_cmd: "", execute_cmd: execute_cmd, needs_gpu:false, needs_reboot:false)
}
}
stage('HipNoGPU Debug Build Test') {
when {
beforeAgent true
Expand Down
1 change: 1 addition & 0 deletions test/gtest/adam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <miopen/adam.hpp>
#include <miopen/miopen.h>

//testing change
struct AdamTestCase
{
std::vector<int> input;
Expand Down
36 changes: 36 additions & 0 deletions test/utils/check_gtests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

FOLDER_PATH="../../test/gtest"

declare -a unmatched_tests

find "$FOLDER_PATH" -type f -name "*.cpp" | while read -r file; do
echo "Processing file: $file"

TEST_P_LINES=$(grep -oP 'TEST_P\(\K\w+,\s*\w+' "$file" | awk -F, '{gsub(/ /,""); print $1 "." $2}')
INSTANTIATE_TEST_LINES=$(grep -oP 'INSTANTIATE_TEST_SUITE_P\(\w+,\s*\K\w+' "$file")

readarray -t TEST_P_ARRAY <<< "$TEST_P_LINES"
readarray -t INSTANTIATE_TEST_ARRAY <<< "$INSTANTIATE_TEST_LINES"

for test in "${TEST_P_ARRAY[@]}"; do
suite=$(echo "$test" | cut -d. -f1)

echo " checking test: ${test}"

if [[ ! " ${INSTANTIATE_TEST_ARRAY[@]} " =~ " ${suite} " ]]; then
unmatched_tests+=("$file: Test '$test' does not have a matching INSTANTIATE_TEST_SUITE_P.")
fi
done
done

echo "----------------------------"

if [[ ${#unmatched_tests[@]} -eq 0 ]]; then
echo "All tests meet the criteria."
else
echo -e "\nUnmatched tests:"
for unmatched in "${unmatched_tests[@]}"; do
echo " $unmatched"
done
fi