aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYannick Brosseau <scientist@fb.com>2016-06-20 11:07:21 -0400
committerShuah Khan <shuahkh@osg.samsung.com>2016-06-27 15:18:26 -0400
commitee65735dd5acecbf335f9aa32e3b129a1de9e184 (patch)
treeca48c22d86c0bb81949c02469afdc5f54b159d2c
parent3aefd1febd882a76e21ca8f61ade03b9c1a2c719 (diff)
selftests/vm: write strlen length instead of sizeof to nr_hugepages
When setting back the initial value to nr_hugepages, the test was writing a length sizeof of the string and checking that strlen was writen. Since those values are not the same, use strlen in both place instead. Also make the error messages more explicit to help in future debugging. Signed-off-by: Yannick Brosseau <scientist@fb.com> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
-rw-r--r--tools/testing/selftests/vm/compaction_test.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/tools/testing/selftests/vm/compaction_test.c b/tools/testing/selftests/vm/compaction_test.c
index 932ff577ffc0..6d1437f895b8 100644
--- a/tools/testing/selftests/vm/compaction_test.c
+++ b/tools/testing/selftests/vm/compaction_test.c
@@ -101,7 +101,7 @@ int check_compaction(unsigned long mem_free, unsigned int hugepage_size)
101 101
102 /* Start with the initial condition of 0 huge pages*/ 102 /* Start with the initial condition of 0 huge pages*/
103 if (write(fd, "0", sizeof(char)) != sizeof(char)) { 103 if (write(fd, "0", sizeof(char)) != sizeof(char)) {
104 perror("Failed to write to /proc/sys/vm/nr_hugepages\n"); 104 perror("Failed to write 0 to /proc/sys/vm/nr_hugepages\n");
105 goto close_fd; 105 goto close_fd;
106 } 106 }
107 107
@@ -110,14 +110,14 @@ int check_compaction(unsigned long mem_free, unsigned int hugepage_size)
110 /* Request a large number of huge pages. The Kernel will allocate 110 /* Request a large number of huge pages. The Kernel will allocate
111 as much as it can */ 111 as much as it can */
112 if (write(fd, "100000", (6*sizeof(char))) != (6*sizeof(char))) { 112 if (write(fd, "100000", (6*sizeof(char))) != (6*sizeof(char))) {
113 perror("Failed to write to /proc/sys/vm/nr_hugepages\n"); 113 perror("Failed to write 100000 to /proc/sys/vm/nr_hugepages\n");
114 goto close_fd; 114 goto close_fd;
115 } 115 }
116 116
117 lseek(fd, 0, SEEK_SET); 117 lseek(fd, 0, SEEK_SET);
118 118
119 if (read(fd, nr_hugepages, sizeof(nr_hugepages)) <= 0) { 119 if (read(fd, nr_hugepages, sizeof(nr_hugepages)) <= 0) {
120 perror("Failed to read from /proc/sys/vm/nr_hugepages\n"); 120 perror("Failed to re-read from /proc/sys/vm/nr_hugepages\n");
121 goto close_fd; 121 goto close_fd;
122 } 122 }
123 123
@@ -136,9 +136,9 @@ int check_compaction(unsigned long mem_free, unsigned int hugepage_size)
136 printf("No of huge pages allocated = %d\n", 136 printf("No of huge pages allocated = %d\n",
137 (atoi(nr_hugepages))); 137 (atoi(nr_hugepages)));
138 138
139 if (write(fd, initial_nr_hugepages, sizeof(initial_nr_hugepages)) 139 if (write(fd, initial_nr_hugepages, strlen(initial_nr_hugepages))
140 != strlen(initial_nr_hugepages)) { 140 != strlen(initial_nr_hugepages)) {
141 perror("Failed to write to /proc/sys/vm/nr_hugepages\n"); 141 perror("Failed to write value to /proc/sys/vm/nr_hugepages\n");
142 goto close_fd; 142 goto close_fd;
143 } 143 }
144 144