mirror of
https://github.com/tailix/libshmemq.git
synced 2024-11-20 11:08:35 -05:00
Cleanup after tests
This commit is contained in:
parent
c1294fd878
commit
19dff0680d
6 changed files with 153 additions and 41 deletions
|
@ -1,15 +1,22 @@
|
|||
#include <shmemq.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static const char name[] = "/foobar";
|
||||
|
||||
static ShmemqError error = SHMEMQ_ERROR_NONE;
|
||||
static Shmemq consumer = NULL;
|
||||
static Shmemq producer = NULL;
|
||||
|
||||
static void on_exit();
|
||||
static void on_signal(int signo);
|
||||
|
||||
int main()
|
||||
{
|
||||
ShmemqError error;
|
||||
atexit(on_exit);
|
||||
signal(SIGABRT, on_signal);
|
||||
|
||||
consumer = shmemq_new(name, true, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
|
@ -22,11 +29,23 @@ int main()
|
|||
shmemq_pop_end(consumer, &error);
|
||||
assert(error == SHMEMQ_ERROR_BUG_POP_END_ON_EMPTY_QUEUE);
|
||||
|
||||
SHMEMQ_DELETE(consumer, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
|
||||
SHMEMQ_DELETE(producer, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void on_exit()
|
||||
{
|
||||
if (consumer) {
|
||||
SHMEMQ_DELETE(consumer, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
}
|
||||
|
||||
if (producer) {
|
||||
SHMEMQ_DELETE(producer, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
void on_signal(const int signo __attribute__((unused)))
|
||||
{
|
||||
on_exit();
|
||||
}
|
||||
|
|
|
@ -1,15 +1,22 @@
|
|||
#include <shmemq.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static const char name[] = "/foobar";
|
||||
|
||||
static ShmemqError error = SHMEMQ_ERROR_NONE;
|
||||
static Shmemq consumer = NULL;
|
||||
static Shmemq producer = NULL;
|
||||
|
||||
static void on_exit();
|
||||
static void on_signal(int signo);
|
||||
|
||||
int main()
|
||||
{
|
||||
ShmemqError error;
|
||||
atexit(on_exit);
|
||||
signal(SIGABRT, on_signal);
|
||||
|
||||
consumer = shmemq_new(name, true, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
|
@ -42,11 +49,23 @@ int main()
|
|||
shmemq_pop_end(consumer, &error);
|
||||
assert(error == SHMEMQ_ERROR_BUG_POP_END_ON_EMPTY_QUEUE);
|
||||
|
||||
SHMEMQ_DELETE(consumer, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
|
||||
SHMEMQ_DELETE(producer, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void on_exit()
|
||||
{
|
||||
if (consumer) {
|
||||
SHMEMQ_DELETE(consumer, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
}
|
||||
|
||||
if (producer) {
|
||||
SHMEMQ_DELETE(producer, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
void on_signal(const int signo __attribute__((unused)))
|
||||
{
|
||||
on_exit();
|
||||
}
|
||||
|
|
|
@ -1,19 +1,26 @@
|
|||
#include <shmemq.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
static const char name[] = "/foobar";
|
||||
static const char hello_world_str[] = "Hello, World!";
|
||||
|
||||
static ShmemqError error = SHMEMQ_ERROR_NONE;
|
||||
static struct Shmemq consumer_shmemq;
|
||||
static Shmemq producer_shmemq = NULL;
|
||||
|
||||
static void on_exit();
|
||||
static void on_signal(int signo);
|
||||
|
||||
int main()
|
||||
{
|
||||
ShmemqError error;
|
||||
atexit(on_exit);
|
||||
signal(SIGABRT, on_signal);
|
||||
|
||||
struct Shmemq consumer_shmemq;
|
||||
memset(&consumer_shmemq, 0, sizeof(consumer_shmemq));
|
||||
|
||||
shmemq_init(&consumer_shmemq, name, true, &error);
|
||||
|
@ -165,11 +172,21 @@ int main()
|
|||
shmemq_pop_end(&consumer_shmemq, &error);
|
||||
assert(error == SHMEMQ_ERROR_BUG_POP_END_ON_EMPTY_QUEUE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void on_exit()
|
||||
{
|
||||
shmemq_finish(&consumer_shmemq, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
|
||||
SHMEMQ_DELETE(producer_shmemq, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
|
||||
return 0;
|
||||
if (producer_shmemq) {
|
||||
SHMEMQ_DELETE(producer_shmemq, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
void on_signal(const int signo __attribute__((unused)))
|
||||
{
|
||||
on_exit();
|
||||
}
|
||||
|
|
|
@ -1,15 +1,22 @@
|
|||
#include <shmemq.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static const char name[] = "/foobar";
|
||||
|
||||
static ShmemqError error = SHMEMQ_ERROR_NONE;
|
||||
static Shmemq consumer = NULL;
|
||||
static Shmemq producer = NULL;
|
||||
|
||||
static void on_exit();
|
||||
static void on_signal(int signo);
|
||||
|
||||
int main()
|
||||
{
|
||||
ShmemqError error;
|
||||
atexit(on_exit);
|
||||
signal(SIGABRT, on_signal);
|
||||
|
||||
consumer = shmemq_new(name, true, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
|
@ -53,11 +60,23 @@ int main()
|
|||
shmemq_push_end(producer, 9, &error);
|
||||
assert(error == SHMEMQ_ERROR_BUG_PUSH_END_OVERFLOW);
|
||||
|
||||
SHMEMQ_DELETE(consumer, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
|
||||
SHMEMQ_DELETE(producer, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void on_exit()
|
||||
{
|
||||
if (consumer) {
|
||||
SHMEMQ_DELETE(consumer, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
}
|
||||
|
||||
if (producer) {
|
||||
SHMEMQ_DELETE(producer, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
void on_signal(const int signo __attribute__((unused)))
|
||||
{
|
||||
on_exit();
|
||||
}
|
||||
|
|
|
@ -1,15 +1,22 @@
|
|||
#include <shmemq.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static const char name[] = "/foobar";
|
||||
|
||||
static ShmemqError error = SHMEMQ_ERROR_NONE;
|
||||
static Shmemq consumer = NULL;
|
||||
static Shmemq producer = NULL;
|
||||
|
||||
static void on_exit();
|
||||
static void on_signal(int signo);
|
||||
|
||||
int main()
|
||||
{
|
||||
ShmemqError error;
|
||||
atexit(on_exit);
|
||||
signal(SIGABRT, on_signal);
|
||||
|
||||
consumer = shmemq_new(name, true, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
|
@ -52,11 +59,23 @@ int main()
|
|||
shmemq_push_end(producer, sizeof(unsigned), &error);
|
||||
assert(error == SHMEMQ_ERROR_BUG_PUSH_END_ON_FULL_QUEUE);
|
||||
|
||||
SHMEMQ_DELETE(consumer, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
|
||||
SHMEMQ_DELETE(producer, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void on_exit()
|
||||
{
|
||||
if (consumer) {
|
||||
SHMEMQ_DELETE(consumer, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
}
|
||||
|
||||
if (producer) {
|
||||
SHMEMQ_DELETE(producer, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
void on_signal(const int signo __attribute__((unused)))
|
||||
{
|
||||
on_exit();
|
||||
}
|
||||
|
|
|
@ -1,15 +1,22 @@
|
|||
#include <shmemq.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static const char name[] = "/foobar";
|
||||
|
||||
static ShmemqError error = SHMEMQ_ERROR_NONE;
|
||||
static Shmemq consumer = NULL;
|
||||
static Shmemq producer = NULL;
|
||||
|
||||
static void on_exit();
|
||||
static void on_signal(int signo);
|
||||
|
||||
int main()
|
||||
{
|
||||
ShmemqError error;
|
||||
atexit(on_exit);
|
||||
signal(SIGABRT, on_signal);
|
||||
|
||||
consumer = shmemq_new(name, true, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
|
@ -32,11 +39,23 @@ int main()
|
|||
shmemq_push_end(producer, sizeof(unsigned), &error);
|
||||
assert(error == SHMEMQ_ERROR_BUG_PUSH_END_ON_FULL_QUEUE);
|
||||
|
||||
SHMEMQ_DELETE(consumer, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
|
||||
SHMEMQ_DELETE(producer, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void on_exit()
|
||||
{
|
||||
if (consumer) {
|
||||
SHMEMQ_DELETE(consumer, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
}
|
||||
|
||||
if (producer) {
|
||||
SHMEMQ_DELETE(producer, &error);
|
||||
assert(error == SHMEMQ_ERROR_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
void on_signal(const int signo __attribute__((unused)))
|
||||
{
|
||||
on_exit();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue