37 {4,
"s0", Mock_indp_member_s0},
38 {2,
"s1", Mock_indp_member_s1},
43 NULL, 0, 7, 3, Mock_indp_struct
99 fprintf(stderr,
"%d: scur_p, ccur_p, n: %lu, %lu, %lu\n",
lgr.nl,
100 (
size_t) scur_p, (
size_t) ccur_p, n);
102 fprintf(stderr,
"logger is full.");
105 lgr.l[
lgr.nl].scur_p = (size_t) scur_p;
106 lgr.l[
lgr.nl].ccur_p = (size_t) ccur_p;
118 fprintf(stderr,
"different numbers of items: %u!=%u\n", nl,
123 for (i = 0; i <
nl; ++i) {
126 fprintf(stderr,
"i:%u, scur_p:%lu!=%lu\n", i, l[i].
scur_p,
133 fprintf(stderr,
"i:%u, ccur_p:%lu!=%lu\n", i, l[i].
ccur_p,
138 if (l[i].
n !=
lgr.l[i].n) {
140 fprintf(stderr,
"i:%u, n:%lu!=%lu\n", i, l[i].
n,
lgr.l[i].n);
161 struct log l[] = { {0, 0, 0} };
162 assert(0 !=
loggerCmp(l,
sizeof(l) /
sizeof(l[0])));
165 struct log l[] = { {1, 0, 0} };
166 assert(0 !=
loggerCmp(l,
sizeof(l) /
sizeof(l[0])));
169 struct log l[] = { {1, 2, 0} };
170 assert(0 !=
loggerCmp(l,
sizeof(l) /
sizeof(l[0])));
173 struct log l[] = { {1, 2, 3} };
174 assert(0 ==
loggerCmp(l,
sizeof(l) /
sizeof(l[0])));
179 struct log l[] = { {1, 2, 3} };
180 assert(0 !=
loggerCmp(l,
sizeof(l) /
sizeof(l[0])));
183 struct log l[] = { {1, 2, 3}, {4, 5, 6} };
184 assert(0 ==
loggerCmp(l,
sizeof(l) /
sizeof(l[0])));
191 const struct log l[],
192 const unsigned int nl)
196 unsigned char *scur_p = (
void *) 1000;
197 unsigned char *ccur_p = (
void *) 2000;
206 scur_p + offset + size,
207 scur_p, ccur_p, 0, 0,
218 struct log l[]= {{1000, 2000, 1},
223 struct log l[]= {{1000, 2000, 1},
229 struct log l[]= {{1000, 2000, 1},
236 struct log l[]= {{1012, 2024, 2},
244 struct log l[]= {{1007, 2013, 1},
257 struct log l[]= {{1000, 2000, 1},
300 NULL, 0, 3, 1, Invmock_indp_struct
328 unsigned char *scur_p = (
void *) 1000;
329 unsigned char *ccur_p = (
void *) 2000;
342 scur_p + offset + size,
352 scur_p + offset + size,
362 scur_p + offset + size,
373 scur_p + offset + size,
394 assert(0x00 == simg[i]);
395 assert(0xff == cimg[i]);
398 memset(simg, 0x00, IMG_SIZE);
399 memset(cimg, 0xff, IMG_SIZE);
401 assert(0xff == simg[0]);
402 assert(0xff == cimg[0]);
404 assert(0x00 == simg[i]);
405 assert(0xff == cimg[i]);
408 memset(simg, 0x00, IMG_SIZE);
409 memset(cimg, 0x00, IMG_SIZE);
414 assert(0xff == simg[i]);
416 assert(0x00 == simg[i]);
419 assert(0xff == cimg[i]);
421 assert(0x00 == cimg[i]);
425 memset(simg, 0x00, IMG_SIZE);
426 memset(cimg, 0x00, IMG_SIZE);
432 assert(0x01 == simg[26]);
433 assert(0x02 == simg[27]);
434 assert(0x03 == simg[28]);
435 assert(0x04 == simg[29]);
436 assert(0x01 == cimg[44]);
437 assert(0x02 == cimg[45]);
438 assert(0x03 == cimg[46]);
439 assert(0x04 == cimg[47]);
441 if (26 <= i && 30 > i) {
442 assert(0x00 == cimg[i]);
443 }
else if (44 <= i && 48 > i) {
444 assert(0x00 == simg[i]);
446 assert(0x00 == simg[i]);
447 assert(0x00 == cimg[i]);
451 memset(simg, 0x00, IMG_SIZE);
452 memset(cimg, 0x00, IMG_SIZE);
459 assert(0x04 == simg[26]);
460 assert(0x03 == simg[27]);
461 assert(0x02 == simg[28]);
462 assert(0x01 == simg[29]);
463 assert(0x01 == cimg[44]);
464 assert(0x02 == cimg[45]);
465 assert(0x03 == cimg[46]);
466 assert(0x04 == cimg[47]);
468 if (26 <= i && 30 > i) {
469 assert(0x00 == cimg[i]);
470 }
else if (44 <= i && 48 > i) {
471 assert(0x00 == simg[i]);
473 assert(0x00 == simg[i]);
474 assert(0x00 == cimg[i]);
487 unsigned char *
cimg_pp[3] = { NULL, NULL, NULL };
492 for (i = 0; i < 3; ++i) {
493 simg_pp[i] = iary[i];
500 for (j = 0; j < 3; ++j) {
505 assert(0xff == cimg[0]);
506 assert(0xff == iary[0][0]);
507 assert(0x00 == iary[1][0]);
508 assert(0x00 == iary[2][0]);
510 for (j = 0; j < 3; ++j) {
511 assert(0x00 == iary[j][i]);
513 assert(0xff == cimg[i]);
516 for (j = 0; j < 3; ++j) {
517 memset(iary[j], 0x00, IMG_SIZE);
521 for (j = 0; j < 3; ++j) {
522 assert(0x00 == iary[j][i]);
526 for (j = 0; j < 3; ++j) {
527 memset(iary[j], 0x00, IMG_SIZE);
529 memset(cimg, 0xff, IMG_SIZE);
532 assert(0xff == cimg[0]);
533 assert(0xff == iary[0][0]);
534 assert(0x00 == iary[1][0]);
535 assert(0x00 == iary[2][0]);
537 for (j = 0; j < 3; ++j) {
538 assert(0x00 == iary[j][i]);
540 assert(0xff == cimg[i]);
543 for (j = 0; j < 3; ++j) {
544 memset(iary[j], 0x00, IMG_SIZE);
546 memset(simg, 0x00, IMG_SIZE);
547 memset(cimg, 0xff, IMG_SIZE);
549 assert(0xff == simg[0]);
551 assert(0x00 == simg[i]);
554 assert(0xff == cimg[i]);
555 for (j = 0; j < 3; ++j) {
556 assert(0x00 == iary[j][i]);
580 assert(0x00 == simg[i]);
581 assert(0xff == cimg[i]);
584 memset(simg, 0x00, IMG_SIZE);
585 memset(cimg, 0xff, IMG_SIZE);
587 assert(0x00 == simg[0]);
588 assert(0x00 == cimg[0]);
590 assert(0x00 == simg[i]);
591 assert(0xff == cimg[i]);
594 memset(simg, 0x00, IMG_SIZE);
595 memset(cimg, 0x00, IMG_SIZE);
600 assert(0xff == simg[i]);
602 assert(0x00 == simg[i]);
605 assert(0xff == cimg[i]);
607 assert(0x00 == cimg[i]);
611 memset(simg, 0x00, IMG_SIZE);
612 memset(cimg, 0x00, IMG_SIZE);
618 assert(0x01 == simg[26]);
619 assert(0x02 == simg[27]);
620 assert(0x03 == simg[28]);
621 assert(0x04 == simg[29]);
622 assert(0x01 == cimg[44]);
623 assert(0x02 == cimg[45]);
624 assert(0x03 == cimg[46]);
625 assert(0x04 == cimg[47]);
627 if (26 <= i && 30 > i) {
628 assert(0x00 == cimg[i]);
629 }
else if (44 <= i && 48 > i) {
630 assert(0x00 == simg[i]);
632 assert(0x00 == simg[i]);
633 assert(0x00 == cimg[i]);
637 memset(simg, 0x00, IMG_SIZE);
638 memset(cimg, 0x00, IMG_SIZE);
645 assert(0x01 == simg[26]);
646 assert(0x02 == simg[27]);
647 assert(0x03 == simg[28]);
648 assert(0x04 == simg[29]);
649 assert(0x04 == cimg[44]);
650 assert(0x03 == cimg[45]);
651 assert(0x02 == cimg[46]);
652 assert(0x01 == cimg[47]);
654 if (26 <= i && 30 > i) {
655 assert(0x00 == cimg[i]);
656 }
else if (44 <= i && 48 > i) {
657 assert(0x00 == simg[i]);
659 assert(0x00 == simg[i]);
660 assert(0x00 == cimg[i]);
676 unsigned char *
cimg_pp[3] = { NULL, NULL, NULL };
681 for (i = 0; i < 3; ++i) {
682 simg_pp[i] = iary[i];
689 for (j = 0; j < 3; ++j) {
694 assert(0x00 == cimg[0]);
695 assert(0x00 == iary[0][0]);
696 assert(0x00 == iary[1][0]);
697 assert(0x00 == iary[2][0]);
699 for (j = 0; j < 3; ++j) {
700 assert(0x00 == iary[j][i]);
702 assert(0xff == cimg[i]);
705 memset(cimg, 0xff, IMG_SIZE);
708 assert(0xff == cimg[i]);
711 for (j = 0; j < 3; ++j) {
712 memset(iary[j], 0x00, IMG_SIZE);
714 memset(cimg, 0xff, IMG_SIZE);
717 assert(0x00 == cimg[0]);
718 assert(0x00 == iary[0][0]);
719 assert(0x00 == iary[1][0]);
720 assert(0x00 == iary[2][0]);
722 for (j = 0; j < 3; ++j) {
723 assert(0x00 == iary[j][i]);
725 assert(0xff == cimg[i]);
728 for (j = 0; j < 3; ++j) {
729 memset(iary[j], 0x00, IMG_SIZE);
731 memset(simg, 0xff, IMG_SIZE);
732 memset(cimg, 0x00, IMG_SIZE);
734 assert(0xff == cimg[0]);
736 assert(0x00 == cimg[i]);
739 assert(0xff == simg[i]);
740 for (j = 0; j < 3; ++j) {
741 assert(0x00 == iary[j][i]);
756 assert(0 == strcmp(
"The member size in server is not the same "
757 "as the size in client; member name: m0", str));
771 assert(0 == strcmp(
"The member size in server is not the same "
772 "as the size in client; member name: ary", str));
777 int main(
int argc,
char *argv[])
780 fprintf(stderr,
"Usage: %s test_id\n", argv[0]);
784 switch (argv[1][0]) {
806 fprintf(stderr,
"Invalid test_id: %s \n", argv[1]);
const struct HIPC_cl_indp_mbr Mock_indp_member_base[]
unsigned char Mock_smdp_base_offset[]
unsigned char Mock_cmdp_s0_size[]
const size_t Invmock_indp_member_idxs_ary[]
Machine-dependent information of a structure used in a client.
static void test_hipcClientUnpack(void)
Machine-independent information of a member of a structure used in a client.
const struct HIPC_cl_indp Invmock_indp
unsigned char Mock_cmdp_s0_offset[]
struct HIPC_cl_dp Mock_cmdp
Machine-independent information of a client.
enum HIPC_errno hipcClientPack(struct HIPC_client *const cl_p, const unsigned char struno, const size_t offset, const size_t size, void *simg, void *cimg)
Packs a range of contents of cimg into simg.
unsigned char Mock_cmdp_s1_offset[]
static void test_hipcClientCheckMbrSize(void)
static void test_hipcClientUnpack_NULLarg(void)
struct HIPC_cl_dp * cmdp_p
Client Machine DePendent data.
static void test_hipcClientPack_NULLarg(void)
struct HIPC_cl_dp_stru Invmock_smdp_struct[]
enum HIPC_errno hipcClientEachMbr(struct HIPC_client *const cl_p, struct HIPC_cl_indp_mbr const *const mbr_p, unsigned char *const begin, unsigned char *const end, unsigned char *const scur_p, unsigned char *const ccur_p, const size_t ssize, const size_t csize, void(*fnc_p)(void *const ccur_p, void *const scur_p, const size_t n))
Calls the function specified by fnc_p with each member between begin and end.
static void test_logger(void)
unsigned char Invmock_rstructsizes[]
const struct HIPC_cl_indp_mbr Mock_indp_member_s0[]
unsigned char Invmock_smdp_base_offset[]
static void test_hipcClientPack(void)
void hipcClientTerminate(struct HIPC_client *const cl_p)
Terminates a HIPC client with releasing the memory space that the client has.
const char * hipcClientGetErrDtlStr(const struct HIPC_client *const cl_p)
Gets a string describing details of an error that has been set to a HIPC client.
struct HIPC_cl_dp_stru Mock_smdp_struct[]
enum HIPC_errno hipcClientCheckMbrSize(struct HIPC_client *const cl_p)
Checks whether sizes of members in structures in a server are the same as sizes in a client...
Machine-independent information of a structure used in a client.
const struct HIPC_cl_indp_mbr Invmock_indp_member_base[]
static int loggerCmp(const struct log l[], const unsigned int nl)
unsigned char Mock_smdp_base_size[]
static int routine_hipcClientEachMbr(const size_t offset, const size_t size, const struct log l[], const unsigned int nl)
unsigned char Mock_lstructsizes[]
struct HIPC_cl_dp Invmock_cmdp
static void test_hipcClientEachMbr_err(void)
const struct HIPC_cl_indp_mbr Mock_indp_member_s1[]
struct HIPC_client invmock
static void loggerAdd(void *const scur_p, void *const ccur_p, const size_t n)
unsigned char Invmock_smdp_base_size[]
const struct HIPC_cl_indp_stru Invmock_indp_struct[]
const struct HIPC_cl_indp Mock_indp
enum HIPC_member_type type
unsigned char Mock_smdp_s0_size[]
static void test_hipcClientEachMbr(void)
struct HIPC_cl_dp_stru Invmock_cmdp_struct[]
unsigned char Invmock_lstructsizes[]
struct HIPC_cl_dp Mock_smdp
unsigned char Invmock_cmdp_base_size[]
void hipcClientSetCimg(struct HIPC_client *const cl_p, const unsigned char struno, void *cimg_p)
Sets a client-side image that is a structure instance of a structure.
unsigned char Mock_smdp_s1_offset[]
enum HIPC_errno hipcClientInit(struct HIPC_client *const cl_p, struct HIPC_client const *const clbase_p)
Initializes a HIPC client with allocating memory space if necessary.
unsigned char ** simg_pp
Server-side images of structures.
unsigned char Mock_smdp_s1_size[]
const size_t Mock_indp_member_idxs_ary[]
unsigned char Mock_rstructsizes[]
struct HIPC_cl_dp_stru Mock_cmdp_struct[]
unsigned char Mock_cmdp_s1_size[]
Machine-dependent information of a client.
unsigned char Mock_smdp_s0_offset[]
struct HIPC_cl_dp_stru * struct_p
struct HIPC_cl_dp * smdp_p
Server Machine DePendent data.
unsigned char Mock_cmdp_base_size[]
enum HIPC_errno hipcClientUnpack(struct HIPC_client *const cl_p, const unsigned char struno, const size_t offset, const size_t size, void *simg, void *cimg)
Unpacks a range of contents of simg into cimg.
int main(int argc, char *argv[])
unsigned char Mock_cmdp_base_offset[]
unsigned char ** cimg_pp
Client-side images of structures.
const struct HIPC_cl_indp_stru Mock_indp_struct[]
unsigned char Invmock_cmdp_base_offset[]
const size_t Mock_indp_member_idxs_as[]
struct HIPC_cl_dp Invmock_smdp