2009-05-18 14:30:17 +00:00
|
|
|
#include <uhub.h>
|
|
|
|
|
|
|
|
#define MAX_USERS 64
|
|
|
|
|
2012-09-27 08:43:53 +00:00
|
|
|
static struct hub_user_manager* uman = 0;
|
2009-07-25 23:47:17 +00:00
|
|
|
static struct hub_user um_user[MAX_USERS];
|
2009-05-18 14:30:17 +00:00
|
|
|
|
2012-09-27 08:43:53 +00:00
|
|
|
EXO_TEST(um_init_1, {
|
|
|
|
sid_t s;
|
|
|
|
uman = uman_init();
|
2009-05-18 14:30:17 +00:00
|
|
|
|
2012-09-27 08:43:53 +00:00
|
|
|
for (s = 0; s < MAX_USERS; s++)
|
2009-05-18 14:30:17 +00:00
|
|
|
{
|
2012-09-27 08:43:53 +00:00
|
|
|
memset(&um_user[s], 0, sizeof(struct hub_user));
|
|
|
|
um_user[s].id.sid = s;
|
2009-05-18 14:30:17 +00:00
|
|
|
}
|
2012-09-27 08:43:53 +00:00
|
|
|
return !!uman;
|
2009-05-18 14:30:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
EXO_TEST(um_shutdown_1, {
|
|
|
|
return uman_shutdown(0) == -1;
|
|
|
|
});
|
|
|
|
|
|
|
|
EXO_TEST(um_shutdown_2, {
|
2012-09-27 08:43:53 +00:00
|
|
|
return uman_shutdown(uman) == 0;
|
2009-05-18 14:30:17 +00:00
|
|
|
});
|
|
|
|
|
2012-09-27 08:43:53 +00:00
|
|
|
EXO_TEST(um_init_2, {
|
|
|
|
uman = uman_init();
|
|
|
|
return !!uman;
|
2009-05-18 14:30:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
EXO_TEST(um_add_1, {
|
2012-09-27 08:43:53 +00:00
|
|
|
return uman_add(uman, &um_user[0]) == 0;
|
2009-05-18 14:30:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
EXO_TEST(um_size_1, {
|
2012-09-27 08:43:53 +00:00
|
|
|
return uman->count == 1;
|
2009-05-18 14:30:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
EXO_TEST(um_remove_1, {
|
2012-09-27 08:43:53 +00:00
|
|
|
return uman_remove(uman, &um_user[0]) == 0;
|
2009-05-18 14:30:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
EXO_TEST(um_size_2, {
|
2012-09-27 08:43:53 +00:00
|
|
|
return uman->count == 0;
|
2009-05-18 14:30:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
EXO_TEST(um_add_2, {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < MAX_USERS; i++)
|
|
|
|
{
|
2012-09-27 08:43:53 +00:00
|
|
|
if (uman_add(uman, &um_user[i]) != 0)
|
2009-05-18 14:30:17 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
});
|
|
|
|
|
|
|
|
EXO_TEST(um_size_3, {
|
2012-09-27 08:43:53 +00:00
|
|
|
return uman->count == MAX_USERS;
|
2009-05-18 14:30:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
EXO_TEST(um_remove_2, {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < MAX_USERS; i++)
|
|
|
|
{
|
2012-09-27 08:43:53 +00:00
|
|
|
if (uman_remove(uman, &um_user[i]) != 0)
|
2009-05-18 14:30:17 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Last test */
|
|
|
|
EXO_TEST(um_shutdown_4, {
|
2012-09-27 08:43:53 +00:00
|
|
|
return uman_shutdown(uman) == 0;
|
2009-05-18 14:30:17 +00:00
|
|
|
});
|