Browse Source

move_pages: honor xlat styles

* numa.c (print_status): Add xlat_style support for status argument.
* tests/move_pages-Xabbrev.c: New file.
* tests/move_pages-Xraw.c: Likewise.
* tests/move_pages-Xverbose.c: Likewise.
* tests/move_pages.c: Handle XLAT_RAW, XLAT_ABBREV, and XLAT_VERBOSE
macros.
* tests/gen_tests.in (move_pages-Xabbrev, move_pages-Xraw,
move_pages-Xverbose): New tests.
* tests/pure_executables.list: Add move_pages-Xabbrev, move_pages-Xraw,
and move_pages-Xverbose.
* tests/.gitignore: Likewise.
Shankara Pailoor 10 months ago
parent
commit
1f66239842

+ 13
- 3
numa.c View File

@@ -121,12 +121,22 @@ static bool
121 121
 print_status(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
122 122
 {
123 123
 	const int status = *(int *) elem_buf;
124
+	bool is_errno = (status < 0) && ((unsigned) -status < nerrnos);
124 125
 
125
-	if (status < 0 && (unsigned) -status < nerrnos)
126
-		tprintf("-%s", errnoent[-status]);
127
-	else
126
+	if (!is_errno || xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV)
128 127
 		tprintf("%d", status);
129 128
 
129
+	if (!is_errno || xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW)
130
+		return true;
131
+
132
+	if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE)
133
+		tprints(" /* ");
134
+
135
+	tprintf("-%s", errnoent[-status]);
136
+
137
+	if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE)
138
+		tprints(" */");
139
+
130 140
 	return true;
131 141
 }
132 142
 

+ 3
- 0
tests/.gitignore View File

@@ -258,6 +258,9 @@ mount-Xabbrev
258 258
 mount-Xraw
259 259
 mount-Xverbose
260 260
 move_pages
261
+move_pages-Xabbrev
262
+move_pages-Xraw
263
+move_pages-Xverbose
261 264
 mq
262 265
 mq_sendrecv
263 266
 mq_sendrecv-read

+ 3
- 0
tests/gen_tests.in View File

@@ -218,6 +218,9 @@ mount-Xabbrev	-a33 -e trace=mount -Xabbrev
218 218
 mount-Xraw	-a33 -e trace=mount -Xraw
219 219
 mount-Xverbose	-a33 -e trace=mount -Xverbose
220 220
 move_pages	-s3
221
+move_pages-Xabbrev	-s3 -e trace=move_pages -Xabbrev
222
+move_pages-Xraw	-s3 -a36 -e trace=move_pages -Xraw
223
+move_pages-Xverbose	-s3 -e trace=move_pages -Xverbose
221 224
 mq	-a32 -e trace=mq_getsetattr,mq_open,mq_unlink
222 225
 mq_sendrecv	-a14 -e trace=mq_open,mq_notify,mq_timedsend,mq_timedreceive,mq_unlink
223 226
 mq_sendrecv-read	-eread=0 -a14 -e trace=mq_open,mq_notify,mq_timedsend,mq_timedreceive,mq_unlink

+ 1
- 0
tests/move_pages-Xabbrev.c View File

@@ -0,0 +1 @@
1
+#include "move_pages.c"

+ 2
- 0
tests/move_pages-Xraw.c View File

@@ -0,0 +1,2 @@
1
+#define XLAT_RAW 1
2
+#include "move_pages.c"

+ 2
- 0
tests/move_pages-Xverbose.c View File

@@ -0,0 +1,2 @@
1
+#define XLAT_VERBOSE 1
2
+#include "move_pages.c"

+ 20
- 0
tests/move_pages.c View File

@@ -106,8 +106,16 @@ print_status_array(const int *const status, const unsigned long count)
106 106
 		if (status[i] >= 0) {
107 107
 			printf("%d", status[i]);
108 108
 		} else {
109
+#if !XLAT_RAW
109 110
 			errno = -status[i];
111
+#endif
112
+#if XLAT_RAW
113
+			printf("%d", status[i]);
114
+#elif XLAT_VERBOSE
115
+			printf("%d /* -%s */", status[i], errno2name());
116
+#else
110 117
 			printf("-%s", errno2name());
118
+#endif
111 119
 		}
112 120
 	}
113 121
 	printf("]");
@@ -133,7 +141,13 @@ print_stat_pages(const unsigned long pid, const unsigned long count,
133 141
 	} else {
134 142
 		print_status_array(status, count);
135 143
 	}
144
+#if XLAT_RAW
145
+	printf(", 0x2) = %s\n", errstr);
146
+#elif XLAT_VERBOSE
147
+	printf(", 0x2 /* MPOL_MF_MOVE */) = %s\n", errstr);
148
+#else /* XLAT_ABBREV */
136 149
 	printf(", MPOL_MF_MOVE) = %s\n", errstr);
150
+#endif
137 151
 }
138 152
 
139 153
 static void
@@ -159,7 +173,13 @@ print_move_pages(const unsigned long pid,
159 173
 		printf("%p", status);
160 174
 	else
161 175
 		printf("[]");
176
+#if XLAT_RAW
177
+	printf(", 0x4) = %s\n", errstr);
178
+#elif XLAT_VERBOSE
179
+	printf(", 0x4 /* MPOL_MF_MOVE_ALL */) = %s\n", errstr);
180
+#else /* XLAT_ABBREV */
162 181
 	printf(", MPOL_MF_MOVE_ALL) = %s\n", errstr);
182
+#endif
163 183
 }
164 184
 
165 185
 int

+ 3
- 0
tests/pure_executables.list View File

@@ -217,6 +217,9 @@ mount-Xabbrev
217 217
 mount-Xraw
218 218
 mount-Xverbose
219 219
 move_pages
220
+move_pages-Xabbrev
221
+move_pages-Xraw
222
+move_pages-Xverbose
220 223
 mq
221 224
 mq_sendrecv
222 225
 mq_sendrecv-read

Loading…
Cancel
Save