#!/bin/sh

export_top_env()
{
	export suite='kunit'
	export testcase='kunit'
	export category='functional'
	export kernel_cmdline='kunit.enable=1'
	export job_origin='kunit.yaml'
	export queue_cmdline_keys=
	export queue='vip'
	export testbox='lkp-hsw-d03'
	export tbox_group='lkp-hsw-d03'
	export job_file='/lkp/jobs/queued/vip/lkp-hsw-d03/kunit-group-01-debian-12-x86_64-20240206.cgz-76031d9536a0-20241217-3269426-unue8v-6.yaml'
	export id='e3cf557f3aa0b7b506d749bd2328b1c01edf3854'
	export queuer_version='/lkp/xsang/.src-20241212-151112'
	export model='Haswell'
	export nr_node=1
	export nr_cpu=8
	export memory='16G'
	export nr_ssd_partitions=1
	export nr_hdd_partitions=4
	export hdd_partitions='/dev/disk/by-id/ata-ST1000DM010-2EP102_W9APNA3R-part*'
	export ssd_partitions='/dev/disk/by-id/ata-INTEL_SSDSC2BB480G6_BTWA6075012T480FGN-part1'
	export rootfs_partition='/dev/disk/by-id/ata-INTEL_SSDSC2BB480G6_BTWA6075012T480FGN-part2'
	export brand='Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz'
	export ucode='0x28'
	export need_kconfig_hw='{"PTP_1588_CLOCK"=>"y"}
{"E1000E"=>"y"}
SATA_AHCI
DRM_I915'
	export commit='76031d9536a076bf023bedbdb1b4317fc801dd67'
	export need_kconfig='{"KPROBE_EVENT_GEN_TEST"=>"m"}
{"STRING_SELFTEST"=>"m"}
{"TEST_DIV64"=>"m"}
{"TEST_BPF"=>"m"}
{"TEST_MIN_HEAP"=>"m"}
{"TEST_STATIC_KEYS"=>"m"}
{"TEST_SCANF"=>"m"}
{"TEST_PRINTF"=>"m"}
{"TEST_KSTRTOX"=>"m"}
{"TEST_STRING_HELPERS"=>"m"}
{"TEST_BITMAP"=>"m"}
{"TEST_UUID"=>"m"}
{"TEST_XARRAY"=>"m"}
{"TEST_OVERFLOW"=>"m"}
{"TEST_RHASHTABLE"=>"m"}
{"TEST_IDA"=>"m"}
{"TEST_MEMCAT_P"=>"m"}
{"TEST_UDELAY"=>"m"}
{"TEST_VMALLOC"=>"m"}
{"DMAPOOL_TEST"=>"m"}
{"TEST_MEMINIT"=>"m"}
{"DMABUF_SELFTESTS"=>"m"}
{"TEST_FREE_PAGES"=>"m"}
{"TEST_BITOPS"=>"m"}
{"TEST_BLACKHOLE_DEV"=>"m"}
{"FIND_BIT_BENCHMARK"=>"m"}
{"TEST_ASYNC_DRIVER_PROBE"=>"m"}
{"GLOB_SELFTEST"=>"m"}
{"PREEMPTIRQ_DELAY_TEST"=>"m"}
{"KPROBES_SANITY_TEST"=>"m"}
{"USB4_DMA_TEST"=>"m"}
{"SCF_TORTURE_TEST"=>"m"}
{"TEST_REF_TRACKER"=>"m"}
{"TEST_LOCKUP"=>"m"}
{"TEST_DHRY"=>"m"}
{"TEST_CLOCKSOURCE_WATCHDOG"=>"m"}
{"REED_SOLOMON_TEST"=>"m"}
{"ASYNC_RAID6_TEST"=>"m"}
{"BACKTRACE_SELF_TEST"=>"m"}
{"ATOMIC64_SELFTEST"=>"m"}
{"TEST_MAPLE_TREE"=>"m"}
{"TEST_HMM"=>"m"}
{"TRANSPARENT_HUGEPAGE"=>"y"}
{"PREEMPT_RT"=>"n"}
{"DEVICE_PRIVATE"=>"y"}
{"ZONE_DEVICE"=>"y"}
{"MEMORY_HOTREMOVE"=>"y"}
{"MEMORY_HOTPLUG"=>"y"}
{"TEST_FPU"=>"m"}
{"KCOV_INSTRUMENT_ALL"=>"n"}
{"SPI_LOOPBACK_TEST"=>"m"}
{"SPI"=>"y"}
{"SPI_MASTER"=>"y"}
{"CRC32_SELFTEST"=>"m"}
{"CRC32"=>"y"}
{"SND_SOC_INTEL_AVS_MACH_I2S_TEST"=>"m"}
{"SND"=>"m"}
{"SND_SOC"=>"m"}
{"SND_SOC_INTEL_AVS"=>"m"}
{"UNICODE_NORMALIZATION_SELFTEST"=>"m"}
{"UNICODE"=>"m"}
{"SYNTH_EVENT_GEN_TEST"=>"m"}
{"SYNTH_EVENTS"=>"y"}
{"NTB_MSI_TEST"=>"m"}
{"NTB_MSI"=>"y"}
{"TEST_LIVEPATCH"=>"m"}
{"LIVEPATCH"=>"y"}
{"DYNAMIC_DEBUG"=>"y"}
{"DYNAMIC_FTRACE_WITH_REGS"=>"y"}
{"TEST_DYNAMIC_DEBUG"=>"m"}
{"DYNAMIC_DEBUG"=>"y"}
{"PROC_FS"=>"y"}
{"DEBUG_FS"=>"y"}
{"PRINTK"=>"y"}
{"FTRACE_STARTUP_TEST"=>"y"}
{"EVENT_TRACE_STARTUP_TEST"=>"y"}
{"GUP_TEST"=>"y"}
{"CRYPTO_MANAGER_DISABLE_TESTS"=>"n"}
{"CRYPTO_MANAGER_EXTRA_TESTS"=>"y"}
{"BTRFS_FS_RUN_SANITY_TESTS"=>"y"}
{"STATIC_CALL_SELFTEST"=>"y"}
{"STMMAC_SELFTESTS"=>"y"}
STMMAC_ETH
PTP_1588_CLOCK_OPTIONAL
{"MCTP_TEST"=>"y"}
{"MCTP"=>"y"}
{"TSNEP_SELFTESTS"=>"y"}
TSNEP
PTP_1588_CLOCK_OPTIONAL
{"NITRO_ENCLAVES_MISC_DEV_TEST"=>"y"}
NITRO_ENCLAVES
{"PCI"=>"y"}
{"HAVE_PCI"=>"y"}
{"VIRT_DRIVERS"=>"y"}
{"FTRACE_SORT_STARTUP_TEST"=>"y"}
{"FUNCTION_TRACER"=>"y"}
{"DYNAMIC_FTRACE"=>"y"}
{"BUILDTIME_MCOUNT_SORT"=>"y"}
{"NET_SELFTESTS"=>"y"}
PHYLIB
{"INET"=>"y"}
{"FIPS_SIGNATURE_SELFTEST"=>"y"}
{"ASYMMETRIC_KEY_TYPE"=>"y"}
ASYMMETRIC_PUBLIC_KEY_SUBTYPE
X509_CERTIFICATE_PARSER
PKCS7_MESSAGE_PARSER
{"CXL_REGION_INVALIDATION_TEST"=>"y"}
{"CXL_REGION"=>"y"}
{"PCI"=>"y"}
CXL_BUS
{"SPARSEMEM"=>"y"}
{"IOMMUFD_TEST"=>"y"}
IOMMUFD
{"DEBUG_KERNEL"=>"y"}
{"FAULT_INJECTION"=>"y"}
{"NVDIMM_SECURITY_TEST"=>"y"}
{"NVDIMM_KEYS"=>"y"}
ENCRYPTED_KEYS
{"BLOCK"=>"y"}
{"BLK_DEV"=>"y"}
{"PHYS_ADDR_T_64BIT"=>"y"}
LIBNVDIMM
{"KEYS"=>"y"}'
	export kconfig='x86_64-rhel-9.4-kunit'
	export enqueue_time='2024-12-17 21:41:47 +0800'
	export _rt='/result/kunit/group-01/lkp-hsw-d03/debian-12-x86_64-20240206.cgz/x86_64-rhel-9.4-kunit/gcc-12/76031d9536a076bf023bedbdb1b4317fc801dd67'
	export compiler='gcc-12'
	export head_commit='80b73e018be27ef73b67516a1a7cd5d22bae31d0'
	export base_commit='fac04efc5c793dccbd07e2d59af9f90b7fc0dca4'
	export branch='linux-devel/devel-hourly-20241209-080651'
	export rootfs='debian-12-x86_64-20240206.cgz'
	export user='lkp'
	export LKP_SERVER='internal-lkp-server'
	export scheduler_version='/lkp/lkp/.src-20241212-153134'
	export arch='x86_64'
	export max_uptime=6000
	export initrd='/osimage/debian/debian-12-x86_64-20240206.cgz'
	export bootloader_append='root=/dev/ram0
RESULT_ROOT=/result/kunit/group-01/lkp-hsw-d03/debian-12-x86_64-20240206.cgz/x86_64-rhel-9.4-kunit/gcc-12/76031d9536a076bf023bedbdb1b4317fc801dd67/0
BOOT_IMAGE=/pkg/linux/x86_64-rhel-9.4-kunit/gcc-12/76031d9536a076bf023bedbdb1b4317fc801dd67/vmlinuz-6.13.0-rc1-00002-g76031d9536a0
branch=linux-devel/devel-hourly-20241209-080651
job=/lkp/jobs/scheduled/lkp-hsw-d03/kunit-group-01-debian-12-x86_64-20240206.cgz-76031d9536a0-20241217-3269426-unue8v-6.yaml
user=lkp
ARCH=x86_64
kconfig=x86_64-rhel-9.4-kunit
commit=76031d9536a076bf023bedbdb1b4317fc801dd67
kunit.enable=1
intremap=posted_msi
max_uptime=6000
LKP_SERVER=internal-lkp-server
nokaslr
selinux=0
debug
apic=debug
sysrq_always_enabled
rcupdate.rcu_cpu_stall_timeout=100
net.ifnames=0
printk.devkmsg=on
panic=-1
softlockup_panic=1
nmi_watchdog=panic
oops=panic
load_ramdisk=2
prompt_ramdisk=0
drbd.minor_count=8
systemd.log_level=err
ignore_loglevel
console=tty0
earlyprintk=ttyS0,115200
console=ttyS0,115200
vga=normal
rw'
	export modules_initrd='/pkg/linux/x86_64-rhel-9.4-kunit/gcc-12/76031d9536a076bf023bedbdb1b4317fc801dd67/modules.cgz'
	export bm_initrd='/osimage/deps/debian-12-x86_64-20240206.cgz/lkp_20241102.cgz,/osimage/deps/debian-12-x86_64-20240206.cgz/rsync-rootfs_20241102.cgz,/osimage/deps/debian-12-x86_64-20240206.cgz/run-ipconfig_20241102.cgz,/osimage/deps/debian-12-x86_64-20240206.cgz/hw_20241102.cgz'
	export ucode_initrd='/osimage/ucode/intel-ucode-20230906.cgz'
	export lkp_initrd='/osimage/user/lkp/lkp-x86_64.cgz'
	export site='inn'
	export LKP_CGI_PORT=80
	export LKP_CIFS_PORT=139
	export job_initrd='/lkp/jobs/scheduled/lkp-hsw-d03/kunit-group-01-debian-12-x86_64-20240206.cgz-76031d9536a0-20241217-3269426-unue8v-6.cgz'
	export last_kernel='4.20.0'
	export kernel='/pkg/linux/x86_64-rhel-9.4-kunit/gcc-12/76031d9536a076bf023bedbdb1b4317fc801dd67/vmlinuz-6.13.0-rc1-00002-g76031d9536a0'
	export result_root='/result/kunit/group-01/lkp-hsw-d03/debian-12-x86_64-20240206.cgz/x86_64-rhel-9.4-kunit/gcc-12/76031d9536a076bf023bedbdb1b4317fc801dd67/0'

	[ -n "$LKP_SRC" ] ||
	export LKP_SRC=/lkp/${user:-lkp}/src
}

run_job()
{
	echo $$ > $TMP/run-job.pid

	. $LKP_SRC/lib/http.sh
	. $LKP_SRC/lib/job.sh
	. $LKP_SRC/lib/env.sh

	export_top_env

	run_setup $LKP_SRC/setup/sanity-check

	run_monitor $LKP_SRC/monitors/wrapper kmsg
	run_monitor $LKP_SRC/monitors/wrapper heartbeat
	run_monitor $LKP_SRC/monitors/wrapper meminfo
	run_monitor $LKP_SRC/monitors/wrapper oom-killer
	run_monitor $LKP_SRC/monitors/plain/watchdog

	run_test group='group-01' $LKP_SRC/tests/wrapper kunit
}

extract_stats()
{
	export stats_part_begin=
	export stats_part_end=

	env group='group-01' $LKP_SRC/stats/wrapper kunit
	$LKP_SRC/stats/wrapper kmsg
	$LKP_SRC/stats/wrapper meminfo

	$LKP_SRC/stats/wrapper time kunit.time
	$LKP_SRC/stats/wrapper dmesg
	$LKP_SRC/stats/wrapper kmsg
	$LKP_SRC/stats/wrapper last_state
	$LKP_SRC/stats/wrapper stderr
	$LKP_SRC/stats/wrapper time
}

"$@"