162306a36Sopenharmony_ci#!/bin/bash
262306a36Sopenharmony_ci# perf metrics value validation
362306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
462306a36Sopenharmony_ciif [ "x$PYTHON" == "x" ]
562306a36Sopenharmony_cithen
662306a36Sopenharmony_ci	if which python3 > /dev/null
762306a36Sopenharmony_ci	then
862306a36Sopenharmony_ci		PYTHON=python3
962306a36Sopenharmony_ci	else
1062306a36Sopenharmony_ci		echo Skipping test, python3 not detected please set environment variable PYTHON.
1162306a36Sopenharmony_ci		exit 2
1262306a36Sopenharmony_ci	fi
1362306a36Sopenharmony_cifi
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_cigrep -q GenuineIntel /proc/cpuinfo || { echo Skipping non-Intel; exit 2; }
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_cipythonvalidator=$(dirname $0)/lib/perf_metric_validation.py
1862306a36Sopenharmony_cirulefile=$(dirname $0)/lib/perf_metric_validation_rules.json
1962306a36Sopenharmony_citmpdir=$(mktemp -d /tmp/__perf_test.program.XXXXX)
2062306a36Sopenharmony_ciworkload="perf bench futex hash -r 2 -s"
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci# Add -debug, save data file and full rule file
2362306a36Sopenharmony_ciecho "Launch python validation script $pythonvalidator"
2462306a36Sopenharmony_ciecho "Output will be stored in: $tmpdir"
2562306a36Sopenharmony_ci$PYTHON $pythonvalidator -rule $rulefile -output_dir $tmpdir -wl "${workload}"
2662306a36Sopenharmony_ciret=$?
2762306a36Sopenharmony_cirm -rf $tmpdir
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ciexit $ret
3062306a36Sopenharmony_ci
31