diff --git a/tests/env/cpu_freq_check.py b/tests/env/cpu_freq_check.py new file mode 100644 index 0000000..ac886d2 --- /dev/null +++ b/tests/env/cpu_freq_check.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 +"""Reframe test to check that CPU target environment variable is correctly set""" + +# Based on work from: +# Copyright 2016-2020 Swiss National Supercomputing Centre (CSCS/ETH Zurich) +# ReFrame Project Developers. See the top-level LICENSE file for details. +# SPDX-License-Identifier: BSD-3-Clause + +import reframe as rfm +import reframe.utility.sanity as sn + + +@rfm.simple_test +class CPUFreqTest(rfm.RunOnlyRegressionTest): + """Checks that CPU frequency is set to 2GHz by default""" + + descr = "Checks whether SLURM_CPU_FREQ_REQ is set to 2GHz by default" + valid_systems = ["archer2:compute"] + valid_prog_environs = ["PrgEnv-cray"] + executable = "./freq_print.sh" + + tags = {"production", "maintenance", "craype"} + + freq = 2000000 + + @sanity_function + def assert_finished(self): + """Sanity check that SLURM_CPU_FREQ_REQ is set""" + return sn.assert_found(f"SLURM_CPU_FREQ_REQ={self.freq}", self.stdout) + + +@rfm.simple_test +class CPUHighFreqTest(rfm.RunOnlyRegressionTest): + """Checks that CPU frequency is set to 2.25GHz""" + + descr = "Checks whether SLURM_CPU_FREQ_REQ can be set to 2.25GHz is set by slurm" + valid_systems = ["archer2:compute"] + valid_prog_environs = ["PrgEnv-cray"] + executable = "./freq_print.sh" + + tags = {"production", "maintenance", "craype"} + + freq = 2250000 + + @run_before("run") + def set_cpu_freq(self): + """Add slurm command line variable to job script to set frequency to 2.25Ghz""" + self.job.launcher.options = ["--cpu-freq=2250000"] + + @sanity_function + def assert_finished(self): + """Sanity check that SLURM_CPU_FREQ_REQ is set""" + return sn.assert_found(f"SLURM_CPU_FREQ_REQ={self.freq}", self.stdout) diff --git a/tests/env/src/freq_print.sh b/tests/env/src/freq_print.sh new file mode 100755 index 0000000..b56e829 --- /dev/null +++ b/tests/env/src/freq_print.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo SLURM_CPU_FREQ_REQ=$SLURM_CPU_FREQ_REQ