Skip to content

Commit 74c1a79

Browse files
committed
kernel_patch_verify: Add patchwise testing option
Use -P to use patchwise to give some LLM powered reviews. Signed-off-by: Nishanth Menon <[email protected]>
1 parent 0afd267 commit 74c1a79

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,22 @@ Example usages:
222222
./kernel_patch_verify -d -1
223223
```
224224
225+
Notes on patchwise
226+
==================
227+
228+
Qualcomm released https://github.com/qualcomm/PatchWise which is an awesome tool
229+
to get some basic automated reviews of the patches done prior to maintainers or
230+
other reviewers reviewing stuff.
231+
232+
To use this use the `-P` option. This requires at least `OPENAI_API_KEY` variable
233+
to be defined, however, you may also use the additional optional variables:
234+
* `OPENAI_API_MODEL` point to appropriate model you'd like to use.
235+
* `OPENAI_API_PROVIDER` if your company uses llm gateways of any form
236+
237+
This test can execute multiple tests already performed, but it is just additional
238+
review tool that is available. Expect to see some significant time spend in this
239+
check.
240+
225241
Some script design stuff:
226242
=========================
227243

kernel_patch_verify

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,11 @@ report_tests() {
681681
fi
682682
done
683683
fi
684+
if [ -f "$LOG_DIR/patch-wise.log" ]; then
685+
log_marker "Patchwise Report:"
686+
cat "$LOG_DIR/patch-wise.log" >> "$LOG_FILE"
687+
fi
688+
684689
if [ -z "$FAIL_TEST" ]; then
685690
logs_me "Passed(ALL): $PASS_TEST"
686691
else
@@ -796,7 +801,7 @@ usage() {
796801

797802
printf '%s\n' \
798803
'' \
799-
"Usage: $APP_NAME [-d | -V] [-j CPUs] [-B build_target] [-T tmp_dir_base] [-l logfile] [-C] [-c defconfig_name] [-n N][-1..9]|[-p patch_dir]|[-b base_branch [-t head_branch]] [-S smatch_script] -U -Z" \
804+
"Usage: $APP_NAME [-d | -V] [-j CPUs] [-B build_target] [-T tmp_dir_base] [-l logfile] [-C] [-P] [-c defconfig_name] [-n N][-1..9]|[-p patch_dir]|[-b base_branch [-t head_branch]] [-S smatch_script] -U -Z" \
800805
''
801806

802807
printf '\t%s\n' \
@@ -808,6 +813,7 @@ usage() {
808813
"-l logfile: report file (defaults to $LOG_FILE)" \
809814
"-L Use llvm to build 'LLVM=1 CC='$ccache clang''" \
810815
"-C: run Complete tests(WARNING: could take significant time!)" \
816+
"-P: run patchwise tests(WARNING: could take significant time!)" \
811817
"-c defconfig: name (default uses current .config + olddefconfig)" \
812818
"-[1..9]: test the tip of current branch (1 to 9 number of patches)" \
813819
"-n N: test the tip of current branch with 'N' number of patches" \
@@ -854,7 +860,7 @@ usage() {
854860

855861
ORIDE=0
856862
DTB_NOSKIP=0
857-
while getopts "S:n:j:c:T:B:l:p:b:t:m:123456789CdDUVZL" opt; do
863+
while getopts "S:n:j:c:T:B:l:p:b:t:m:123456789CdDUVZLP" opt; do
858864
case $opt in
859865
j)
860866
KM_CPUS=$OPTARG
@@ -937,6 +943,14 @@ while getopts "S:n:j:c:T:B:l:p:b:t:m:123456789CdDUVZL" opt; do
937943
exit 1
938944
fi
939945
;;
946+
P)
947+
PATCHWISE=1
948+
APPS_NEEDED="$APPS_NEEDED patchwise"
949+
if [ -z "$OPENAI_API_KEY" ]; then
950+
usage "Cannot run patchwise without OPENAI_API_KEY"
951+
exit 1
952+
fi
953+
;;
940954
[1-9])
941955
TEST_TOP=yes
942956
if [ -n "${PATCH_DIR}${BASE_BRANCH}${TEST_BRANCH}" ]; then
@@ -1166,6 +1180,27 @@ done
11661180

11671181
tests_end
11681182

1183+
if [ "$PATCHWISE" -eq 1 ]; then
1184+
PATCHWISE_ARGS=""
1185+
if [ "$OPENAI_API_PROVIDER" ]; then
1186+
PATCHWISE_ARGS="$PATCHWISE_ARGS --provider=$OPENAI_API_PROVIDER"
1187+
fi
1188+
if [ "$OPENAI_API_MODEL" ]; then
1189+
PATCHWISE_ARGS="$PATCHWISE_ARGS --model=$OPENAI_API_MODEL"
1190+
fi
1191+
PATCHWISE_ARGS="$PATCHWISE_ARGS --repo-path . --commits=HEAD...HEAD~$PATCHCOUNT"
1192+
echo "Starting Patchwise for $PATCHCOUNT patches.. Please be patient"
1193+
if [ -n "$CURRENT_BRANCH" ]; then
1194+
echo "Restoring to $CURRENT_BRANCH branch"
1195+
git reset --hard 2>/dev/null
1196+
git checkout "$CURRENT_BRANCH" 2>/dev/null
1197+
fi
1198+
if [ -d '/tmp/patchwise/sandbox/kernel' ]; then
1199+
rm -rf /tmp/patchwise/sandbox/kernel
1200+
fi
1201+
patchwise $PATCHWISE_ARGS --log-file "$LOG_DIR/patch-wise.log"
1202+
fi
1203+
11691204
NOW_SEC=$(date "+%s")
11701205
DELTAP=$((NOW_SEC - STARTP_SEC))
11711206
echo

0 commit comments

Comments
 (0)