1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
// SPDX-License-Identifier: MIT
/*
* Copyright © 2022 Intel Corporation
*/
#include <dirent.h>
#include <sys/stat.h>
#include "igt.h"
#include "igt_hwmon.h"
#include "igt_sysfs.h"
/**
* TEST: intel hwmon
* Description: Tests for intel hwmon
* Category: Core
* Mega feature: RAS
* Sub-category: RAS tests
* Functionality: hwmon
* Test category: functionality
*
* SUBTEST: hwmon-read
* Description: Verify we can read all hwmon attributes
*
* SUBTEST: hwmon-write
* Description: Verify writable hwmon attributes
*/
IGT_TEST_DESCRIPTION("Tests for intel hwmon");
static void hwmon_read(int hwm)
{
struct dirent *de;
char val[128];
DIR *dir;
dir = fdopendir(dup(hwm));
igt_assert(dir);
rewinddir(dir);
while ((de = readdir(dir))) {
if (de->d_type != DT_REG || !strcmp(de->d_name, "uevent"))
continue;
igt_assert(igt_sysfs_scanf(hwm, de->d_name, "%127s", val) == 1);
igt_debug("'%s': %s\n", de->d_name, val);
}
closedir(dir);
}
static void hwmon_write(int hwm)
{
igt_sysfs_rw_attr_t rw;
struct dirent *de;
struct stat st;
DIR *dir;
dir = fdopendir(dup(hwm));
igt_assert(dir);
rewinddir(dir);
rw.dir = hwm;
rw.start = 1;
rw.tol = 0.1;
while ((de = readdir(dir))) {
if (de->d_type != DT_REG || !strcmp(de->d_name, "uevent"))
continue;
igt_assert(!fstatat(hwm, de->d_name, &st, 0));
if (!(st.st_mode & 0222))
continue;
rw.attr = de->d_name;
igt_sysfs_rw_attr_verify(&rw);
}
closedir(dir);
}
igt_main
{
int fd, hwm;
igt_fixture {
fd = drm_open_driver_master(DRIVER_INTEL | DRIVER_XE);
hwm = igt_hwmon_open(fd);
igt_require(hwm >= 0);
}
igt_describe("Verify we can read all hwmon attributes");
igt_subtest("hwmon-read") {
hwmon_read(hwm);
}
igt_describe("Verify writable hwmon attributes");
igt_subtest("hwmon-write") {
hwmon_write(hwm);
}
igt_fixture {
close(hwm);
drm_close_driver(fd);
}
}
|