Commit 56661564 authored by Shuah Khan's avatar Shuah Khan

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: default avatarShuah Khan <shuahkh@osg.samsung.com>
parent b3616904
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include <linux/msg.h> #include <linux/msg.h>
#include <fcntl.h> #include <fcntl.h>
#include "../kselftest.h"
#define MAX_MSG_SIZE 32 #define MAX_MSG_SIZE 32
struct msg1 { struct msg1 {
...@@ -195,58 +197,58 @@ int main(int argc, char **argv) ...@@ -195,58 +197,58 @@ int main(int argc, char **argv)
if (getuid() != 0) { if (getuid() != 0) {
printf("Please run the test as root - Exiting.\n"); printf("Please run the test as root - Exiting.\n");
exit(1); return ksft_exit_fail();
} }
msgque.key = ftok(argv[0], 822155650); msgque.key = ftok(argv[0], 822155650);
if (msgque.key == -1) { if (msgque.key == -1) {
printf("Can't make key\n"); printf("Can't make key: %d\n", -errno);
return -errno; return ksft_exit_fail();
} }
msgque.msq_id = msgget(msgque.key, IPC_CREAT | IPC_EXCL | 0666); msgque.msq_id = msgget(msgque.key, IPC_CREAT | IPC_EXCL | 0666);
if (msgque.msq_id == -1) { if (msgque.msq_id == -1) {
err = -errno; err = -errno;
printf("Can't create queue\n"); printf("Can't create queue: %d\n", err);
goto err_out; goto err_out;
} }
err = fill_msgque(&msgque); err = fill_msgque(&msgque);
if (err) { if (err) {
printf("Failed to fill queue\n"); printf("Failed to fill queue: %d\n", err);
goto err_destroy; goto err_destroy;
} }
err = dump_queue(&msgque); err = dump_queue(&msgque);
if (err) { if (err) {
printf("Failed to dump queue\n"); printf("Failed to dump queue: %d\n", err);
goto err_destroy; goto err_destroy;
} }
err = check_and_destroy_queue(&msgque); err = check_and_destroy_queue(&msgque);
if (err) { if (err) {
printf("Failed to check and destroy queue\n"); printf("Failed to check and destroy queue: %d\n", err);
goto err_out; goto err_out;
} }
err = restore_queue(&msgque); err = restore_queue(&msgque);
if (err) { if (err) {
printf("Failed to restore queue\n"); printf("Failed to restore queue: %d\n", err);
goto err_destroy; goto err_destroy;
} }
err = check_and_destroy_queue(&msgque); err = check_and_destroy_queue(&msgque);
if (err) { if (err) {
printf("Failed to test queue\n"); printf("Failed to test queue: %d\n", err);
goto err_out; goto err_out;
} }
return 0; return ksft_exit_pass();
err_destroy: err_destroy:
if (msgctl(msgque.msq_id, IPC_RMID, 0)) { if (msgctl(msgque.msq_id, IPC_RMID, 0)) {
printf("Failed to destroy queue: %d\n", -errno); printf("Failed to destroy queue: %d\n", -errno);
return -errno; return ksft_exit_fail();
} }
err_out: err_out:
return err; return ksft_exit_fail();
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment