#!/bin/sh

export_top_env()
{
	export suite='ltp'
	export testcase='ltp'
	export category='functional'
	export need_memory='4G'
	export job_origin='ltp-mm.yaml'
	export queue_cmdline_keys=
	export queue='vip'
	export testbox='lkp-kbl-d01'
	export tbox_group='lkp-kbl-d01'
	export job_file='/lkp/jobs/queued/vip/lkp-kbl-d01/ltp-1HDD-mm-00-debian-12-x86_64-20240206.cgz-13671c9499a4-20250324-610813-10qouay-0.yaml'
	export id='06b32b50a43d886823b7322a54a2f544f192a319'
	export queuer_version='/lkp/xsang/.src-20250324-091955'
	export model='Kaby Lake'
	export nr_node=1
	export nr_cpu=8
	export memory='32G'
	export nr_ssd_partitions=1
	export nr_hdd_partitions=4
	export hdd_partitions='/dev/disk/by-id/ata-ST1000DM003-1CH162_Z1D3X32H-part*'
	export ssd_partitions='/dev/disk/by-id/ata-CT1000BX500SSD1_2203E5FF08F0-part1'
	export rootfs_partition='/dev/disk/by-id/ata-CT1000BX500SSD1_2203E5FF08F0-part2'
	export brand='Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz'
	export ucode='0xf4'
	export need_kconfig_hw='{"PTP_1588_CLOCK"=>"y"}
{"E1000E"=>"y"}
SATA_AHCI'
	export need_kconfig='BLK_DEV_SD
SCSI
{"BLOCK"=>"y"}
SATA_AHCI
SATA_AHCI_PLATFORM
ATA
{"PCI"=>"y"}
BLK_DEV_LOOP
{"CAN"=>"m"}
{"CAN_DEV"=>"m"}
{"CAN_RAW"=>"m"}
{"CAN_VCAN"=>"m"}
{"MINIX_FS"=>"m"}
{"EXPERT"=>"y"}
{"CHECKPOINT_RESTORE"=>"y"}'
	export commit='13671c9499a4883f6bece7229463ff89a48709f6'
	export initrds='linux_headers'
	export kconfig='x86_64-rhel-9.4-ltp'
	export enqueue_time='2025-03-24 15:54:14 +0800'
	export _rt='/result/ltp/1HDD-mm-00/lkp-kbl-d01/debian-12-x86_64-20240206.cgz/x86_64-rhel-9.4-ltp/gcc-12/13671c9499a4883f6bece7229463ff89a48709f6'
	export compiler='gcc-12'
	export head_commit='7d84753a4c0a3d482eaa681a8371618ab064b03b'
	export base_commit='4701f33a10702d5fc577c32434eb62adde0a1ae1'
	export branch='linux-devel/devel-hourly-20250321-100514'
	export rootfs='debian-12-x86_64-20240206.cgz'
	export LKP_SERVER='internal-lkp-server'
	export scheduler_version='/lkp/lkp/.src-20250324-114855'
	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/ltp/1HDD-mm-00/lkp-kbl-d01/debian-12-x86_64-20240206.cgz/x86_64-rhel-9.4-ltp/gcc-12/13671c9499a4883f6bece7229463ff89a48709f6/0
BOOT_IMAGE=/pkg/linux/x86_64-rhel-9.4-ltp/gcc-12/13671c9499a4883f6bece7229463ff89a48709f6/vmlinuz-6.14.0-rc6-00001-g13671c9499a4
branch=linux-devel/devel-hourly-20250321-100514
job=/lkp/jobs/scheduled/lkp-kbl-d01/ltp-1HDD-mm-00-debian-12-x86_64-20240206.cgz-13671c9499a4-20250324-610813-10qouay-0.yaml
user=lkp
ARCH=x86_64
kconfig=x86_64-rhel-9.4-ltp
commit=13671c9499a4883f6bece7229463ff89a48709f6
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-ltp/gcc-12/13671c9499a4883f6bece7229463ff89a48709f6/modules.cgz'
	export linux_headers_initrd='/pkg/linux/x86_64-rhel-9.4-ltp/gcc-12/13671c9499a4883f6bece7229463ff89a48709f6/linux-headers.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/fs_20241102.cgz,/osimage/deps/debian-12-x86_64-20240206.cgz/ltp_20250322.cgz,/osimage/pkg/debian-12-x86_64-20240206.cgz/ltp-x86_64-042eff32a-1_20250322.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-kbl-d01/ltp-1HDD-mm-00-debian-12-x86_64-20240206.cgz-13671c9499a4-20250324-610813-10qouay-0.cgz'
	export last_kernel='4.20.0'
	export acpi_rsdp='0x000f05b0'
	export kernel='/pkg/linux/x86_64-rhel-9.4-ltp/gcc-12/13671c9499a4883f6bece7229463ff89a48709f6/vmlinuz-6.14.0-rc6-00001-g13671c9499a4'
	export result_root='/result/ltp/1HDD-mm-00/lkp-kbl-d01/debian-12-x86_64-20240206.cgz/x86_64-rhel-9.4-ltp/gcc-12/13671c9499a4883f6bece7229463ff89a48709f6/0'
	export user='lkp'

	[ -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 nr_hdd=1 $LKP_SRC/setup/disk

	run_setup $LKP_SRC/setup/fs

	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 test='mm-00' $LKP_SRC/tests/wrapper ltp
}

extract_stats()
{
	export stats_part_begin=
	export stats_part_end=

	env test='mm-00' $LKP_SRC/stats/wrapper ltp
	$LKP_SRC/stats/wrapper kmsg
	$LKP_SRC/stats/wrapper meminfo

	$LKP_SRC/stats/wrapper time ltp.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
}

"$@"