Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'linux-kselftest-fixes-5.15-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull Kselftest fixes from Shuah Khan:

- fix to Kselftest common framework header install to run before other
targets for it work correctly in parallel build case.

- fixes to kvm test to not ignore fscanf() returns which could result
in inconsistent test behavior and failures.

* tag 'linux-kselftest-fixes-5.15-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
selftests: kvm: fix get_run_delay() ignoring fscanf() return warn
selftests: kvm: move get_run_delay() into lib/test_util
selftests:kvm: fix get_trans_hugepagesz() ignoring fscanf() return warn
selftests:kvm: fix get_warnings_count() ignoring fscanf() return warn
selftests: be sure to make khdr before other targets

+27 -33
+3
tools/testing/selftests/kvm/include/test_util.h
··· 95 95 uint32_t flag; 96 96 }; 97 97 98 + #define MIN_RUN_DELAY_NS 200000UL 99 + 98 100 bool thp_configured(void); 99 101 size_t get_trans_hugepagesz(void); 100 102 size_t get_def_hugetlb_pagesz(void); ··· 104 102 size_t get_backing_src_pagesz(uint32_t i); 105 103 void backing_src_help(void); 106 104 enum vm_mem_backing_src_type parse_backing_src_type(const char *type_name); 105 + long get_run_delay(void); 107 106 108 107 /* 109 108 * Whether or not the given source type is shared memory (as opposed to
+21 -1
tools/testing/selftests/kvm/lib/test_util.c
··· 11 11 #include <stdlib.h> 12 12 #include <time.h> 13 13 #include <sys/stat.h> 14 + #include <sys/syscall.h> 14 15 #include <linux/mman.h> 15 16 #include "linux/kernel.h" 16 17 ··· 130 129 { 131 130 size_t size; 132 131 FILE *f; 132 + int ret; 133 133 134 134 TEST_ASSERT(thp_configured(), "THP is not configured in host kernel"); 135 135 136 136 f = fopen("/sys/kernel/mm/transparent_hugepage/hpage_pmd_size", "r"); 137 137 TEST_ASSERT(f != NULL, "Error in opening transparent_hugepage/hpage_pmd_size"); 138 138 139 - fscanf(f, "%ld", &size); 139 + ret = fscanf(f, "%ld", &size); 140 + ret = fscanf(f, "%ld", &size); 141 + TEST_ASSERT(ret < 1, "Error reading transparent_hugepage/hpage_pmd_size"); 140 142 fclose(f); 141 143 142 144 return size; ··· 303 299 backing_src_help(); 304 300 TEST_FAIL("Unknown backing src type: %s", type_name); 305 301 return -1; 302 + } 303 + 304 + long get_run_delay(void) 305 + { 306 + char path[64]; 307 + long val[2]; 308 + FILE *fp; 309 + 310 + sprintf(path, "/proc/%ld/schedstat", syscall(SYS_gettid)); 311 + fp = fopen(path, "r"); 312 + /* Return MIN_RUN_DELAY_NS upon failure just to be safe */ 313 + if (fscanf(fp, "%ld %ld ", &val[0], &val[1]) < 2) 314 + val[1] = MIN_RUN_DELAY_NS; 315 + fclose(fp); 316 + 317 + return val[1]; 306 318 }
-16
tools/testing/selftests/kvm/steal_time.c
··· 10 10 #include <sched.h> 11 11 #include <pthread.h> 12 12 #include <linux/kernel.h> 13 - #include <sys/syscall.h> 14 13 #include <asm/kvm.h> 15 14 #include <asm/kvm_para.h> 16 15 ··· 19 20 20 21 #define NR_VCPUS 4 21 22 #define ST_GPA_BASE (1 << 30) 22 - #define MIN_RUN_DELAY_NS 200000UL 23 23 24 24 static void *st_gva[NR_VCPUS]; 25 25 static uint64_t guest_stolen_time[NR_VCPUS]; ··· 214 216 } 215 217 216 218 #endif 217 - 218 - static long get_run_delay(void) 219 - { 220 - char path[64]; 221 - long val[2]; 222 - FILE *fp; 223 - 224 - sprintf(path, "/proc/%ld/schedstat", syscall(SYS_gettid)); 225 - fp = fopen(path, "r"); 226 - fscanf(fp, "%ld %ld ", &val[0], &val[1]); 227 - fclose(fp); 228 - 229 - return val[1]; 230 - } 231 219 232 220 static void *do_steal_time(void *arg) 233 221 {
+2 -1
tools/testing/selftests/kvm/x86_64/mmio_warning_test.c
··· 82 82 FILE *f; 83 83 84 84 f = popen("dmesg | grep \"WARNING:\" | wc -l", "r"); 85 - fscanf(f, "%d", &warnings); 85 + if (fscanf(f, "%d", &warnings) < 1) 86 + warnings = 0; 86 87 fclose(f); 87 88 88 89 return warnings;
-15
tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c
··· 14 14 #include <stdint.h> 15 15 #include <time.h> 16 16 #include <sched.h> 17 - #include <sys/syscall.h> 18 17 19 18 #define VCPU_ID 5 20 19 ··· 95 96 GUEST_ASSERT(rs->time[RUNSTATE_runnable] >= MIN_STEAL_TIME); 96 97 97 98 GUEST_DONE(); 98 - } 99 - 100 - static long get_run_delay(void) 101 - { 102 - char path[64]; 103 - long val[2]; 104 - FILE *fp; 105 - 106 - sprintf(path, "/proc/%ld/schedstat", syscall(SYS_gettid)); 107 - fp = fopen(path, "r"); 108 - fscanf(fp, "%ld %ld ", &val[0], &val[1]); 109 - fclose(fp); 110 - 111 - return val[1]; 112 99 } 113 100 114 101 static int cmp_timespec(struct timespec *a, struct timespec *b)
+1
tools/testing/selftests/lib.mk
··· 48 48 # When local build is done, headers are installed in the default 49 49 # INSTALL_HDR_PATH usr/include. 50 50 .PHONY: khdr 51 + .NOTPARALLEL: 51 52 khdr: 52 53 ifndef KSFT_KHDR_INSTALL_DONE 53 54 ifeq (1,$(DEFAULT_INSTALL_HDR_PATH))