diff options
author | Shuah Khan <shuahkh@osg.samsung.com> | 2014-10-03 11:07:12 -0400 |
---|---|---|
committer | Shuah Khan <shuahkh@osg.samsung.com> | 2014-11-17 12:39:15 -0500 |
commit | 56661564e1fea94c42289edd59361a1f87932410 (patch) | |
tree | 6998f03ba77f38bb40506b1ac4785b8b52adbd13 /tools/testing | |
parent | b36169041c07378aa17e8afff643aed89be9acd4 (diff) |
selftests/ipc: change test to use ksft framework
Change ipc test to use kselftest framework to report
test results. With this change this test exits with
EXIT_FAIL instead of -errno. Changed print errno in
test fail messages to not loose that information.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Diffstat (limited to 'tools/testing')
-rw-r--r-- | tools/testing/selftests/ipc/msgque.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/tools/testing/selftests/ipc/msgque.c b/tools/testing/selftests/ipc/msgque.c index 552f0810bffb..1b2ce334bb3f 100644 --- a/tools/testing/selftests/ipc/msgque.c +++ b/tools/testing/selftests/ipc/msgque.c | |||
@@ -5,6 +5,8 @@ | |||
5 | #include <linux/msg.h> | 5 | #include <linux/msg.h> |
6 | #include <fcntl.h> | 6 | #include <fcntl.h> |
7 | 7 | ||
8 | #include "../kselftest.h" | ||
9 | |||
8 | #define MAX_MSG_SIZE 32 | 10 | #define MAX_MSG_SIZE 32 |
9 | 11 | ||
10 | struct msg1 { | 12 | struct msg1 { |
@@ -195,58 +197,58 @@ int main(int argc, char **argv) | |||
195 | 197 | ||
196 | if (getuid() != 0) { | 198 | if (getuid() != 0) { |
197 | printf("Please run the test as root - Exiting.\n"); | 199 | printf("Please run the test as root - Exiting.\n"); |
198 | exit(1); | 200 | return ksft_exit_fail(); |
199 | } | 201 | } |
200 | 202 | ||
201 | msgque.key = ftok(argv[0], 822155650); | 203 | msgque.key = ftok(argv[0], 822155650); |
202 | if (msgque.key == -1) { | 204 | if (msgque.key == -1) { |
203 | printf("Can't make key\n"); | 205 | printf("Can't make key: %d\n", -errno); |
204 | return -errno; | 206 | return ksft_exit_fail(); |
205 | } | 207 | } |
206 | 208 | ||
207 | msgque.msq_id = msgget(msgque.key, IPC_CREAT | IPC_EXCL | 0666); | 209 | msgque.msq_id = msgget(msgque.key, IPC_CREAT | IPC_EXCL | 0666); |
208 | if (msgque.msq_id == -1) { | 210 | if (msgque.msq_id == -1) { |
209 | err = -errno; | 211 | err = -errno; |
210 | printf("Can't create queue\n"); | 212 | printf("Can't create queue: %d\n", err); |
211 | goto err_out; | 213 | goto err_out; |
212 | } | 214 | } |
213 | 215 | ||
214 | err = fill_msgque(&msgque); | 216 | err = fill_msgque(&msgque); |
215 | if (err) { | 217 | if (err) { |
216 | printf("Failed to fill queue\n"); | 218 | printf("Failed to fill queue: %d\n", err); |
217 | goto err_destroy; | 219 | goto err_destroy; |
218 | } | 220 | } |
219 | 221 | ||
220 | err = dump_queue(&msgque); | 222 | err = dump_queue(&msgque); |
221 | if (err) { | 223 | if (err) { |
222 | printf("Failed to dump queue\n"); | 224 | printf("Failed to dump queue: %d\n", err); |
223 | goto err_destroy; | 225 | goto err_destroy; |
224 | } | 226 | } |
225 | 227 | ||
226 | err = check_and_destroy_queue(&msgque); | 228 | err = check_and_destroy_queue(&msgque); |
227 | if (err) { | 229 | if (err) { |
228 | printf("Failed to check and destroy queue\n"); | 230 | printf("Failed to check and destroy queue: %d\n", err); |
229 | goto err_out; | 231 | goto err_out; |
230 | } | 232 | } |
231 | 233 | ||
232 | err = restore_queue(&msgque); | 234 | err = restore_queue(&msgque); |
233 | if (err) { | 235 | if (err) { |
234 | printf("Failed to restore queue\n"); | 236 | printf("Failed to restore queue: %d\n", err); |
235 | goto err_destroy; | 237 | goto err_destroy; |
236 | } | 238 | } |
237 | 239 | ||
238 | err = check_and_destroy_queue(&msgque); | 240 | err = check_and_destroy_queue(&msgque); |
239 | if (err) { | 241 | if (err) { |
240 | printf("Failed to test queue\n"); | 242 | printf("Failed to test queue: %d\n", err); |
241 | goto err_out; | 243 | goto err_out; |
242 | } | 244 | } |
243 | return 0; | 245 | return ksft_exit_pass(); |
244 | 246 | ||
245 | err_destroy: | 247 | err_destroy: |
246 | if (msgctl(msgque.msq_id, IPC_RMID, 0)) { | 248 | if (msgctl(msgque.msq_id, IPC_RMID, 0)) { |
247 | printf("Failed to destroy queue: %d\n", -errno); | 249 | printf("Failed to destroy queue: %d\n", -errno); |
248 | return -errno; | 250 | return ksft_exit_fail(); |
249 | } | 251 | } |
250 | err_out: | 252 | err_out: |
251 | return err; | 253 | return ksft_exit_fail(); |
252 | } | 254 | } |