Hi Maciej, On 2/9/2024 6:01 AM, Maciej Wieczor-Retman wrote: ... > diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h > index 5116ea082d03..f434a6543b4f 100644 > --- a/tools/testing/selftests/resctrl/resctrl.h > +++ b/tools/testing/selftests/resctrl/resctrl.h > @@ -136,7 +136,9 @@ int get_domain_id(const char *resource, int cpu_no, int *domain_id); > int mount_resctrlfs(void); > int umount_resctrlfs(void); > int validate_bw_report_request(char *bw_report); > -bool validate_resctrl_feature_request(const char *resource, const char *feature); > +bool resctrl_resource_exists(const char *resource); > +bool resctrl_mon_feature_exists(const char *resource, const char *feature); > +bool resource_info_file_exists(const char *resource, const char *file); Portion of next patch sneaked in here. > bool test_resource_feature_check(const struct resctrl_test *test); > char *fgrep(FILE *inf, const char *str); > int taskset_benchmark(pid_t bm_pid, int cpu_no, cpu_set_t *old_affinity); > diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c > index 8a183c73bc23..af4f800ab23d 100644 > --- a/tools/testing/selftests/resctrl/resctrlfs.c > +++ b/tools/testing/selftests/resctrl/resctrlfs.c > @@ -708,20 +708,16 @@ char *fgrep(FILE *inf, const char *str) > } > > /* > - * validate_resctrl_feature_request - Check if requested feature is valid. > - * @resource: Required resource (e.g., MB, L3, L2, L3_MON, etc.) > - * @feature: Required monitor feature (in mon_features file). Can only be > - * set for L3_MON. Must be NULL for all other resources. > + * resctrl_resource_exists - Check if a resource is supported. > + * @resource: Resctrl resource (e.g., MB, L3, L2, L3_MON, etc.) > * > - * Return: True if the resource/feature is supported, else false. False is > + * Return: True if the resource is supported, else false. False is > * also returned if resctrl FS is not mounted. > */ > -bool validate_resctrl_feature_request(const char *resource, const char *feature) > +bool resctrl_resource_exists(const char *resource) > { > char res_path[PATH_MAX]; > struct stat statbuf; > - char *res; > - FILE *inf; > int ret; > > if (!resource) > @@ -736,8 +732,25 @@ bool validate_resctrl_feature_request(const char *resource, const char *feature) > if (stat(res_path, &statbuf)) > return false; > > + return true; > +} > + > +/* > + * resctrl_mon_feature_exists - Check if requested monitoring feature is valid. > + * @resource: Resource that uses the mon_features file. Currently only L3_MON > + * is valid. > + * @feature: Required monitor feature (in mon_features file). > + * > + * Return: True if the feature is supported, else false. > + */ > +bool resctrl_mon_feature_exists(const char *resource, const char *feature) > +{ > + char res_path[PATH_MAX]; > + char *res; > + FILE *inf; > + > if (!feature) Now that resource is a new parameter should it be checked also? It is not obvious why only one parameter is checked. Reinette