#!/bin/bash

_install() {
    return 0
}

_check() {
	_check="PASS"

    dmidecode -t3 |grep Version|grep -q 'V[456]'
    if [[ $? -eq 0 ]];then
        tsc_freq=`grep tsc /var/log/dmesg|grep processor|sed -n 's/.* \([0-9\.]\+\) MHz.*/\1/p'`
        tsc_freq=`printf "%0.1f\n" $(echo "scale=4;$tsc_freq/1000"|bc)`
        cpu_freq=`lscpu|grep 'Model name'|sed -n 's/.* \([0-9\.]\+\)GHz.*/\1/p'`
        cpu_freq=`printf "%0.1f\n" $cpu_freq`
    
        if [[ $tsc_freq != $cpu_freq ]];then
            _check="FAIL"
            PRINT_ERR "[ERROR] tsc freq $tsc_freq GHz, Not Match cpu freq $cpu_freq GHz"
        fi
    fi
    [[ $ARCH = 'aarch64' ]] || [[ $(cat /sys/devices/system/clocksource/clocksource0/current_clocksource) == tsc ]] || {
        _check="FAIL"
        PRINT_ERR "[ERROR] clocksource not tsc"
    }
}
