|
|
@@ -44,7 +44,8 @@
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
#include "ais_types.h"
|
|
|
-#include "ais_ckpt.h"
|
|
|
+#include "saCkpt.h"
|
|
|
+#include "sa_error.h"
|
|
|
|
|
|
#define SECONDS_TO_EXPIRE 4
|
|
|
|
|
|
@@ -58,7 +59,7 @@ void printSaNameT (SaNameT *name)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-SaVersionT version = { 'A', 1, 1 };
|
|
|
+SaVersionT version = { 'B', 1, 1 };
|
|
|
|
|
|
SaNameT checkpointName = { 5, "abra\0" };
|
|
|
|
|
|
@@ -72,14 +73,15 @@ SaCkptCheckpointCreationAttributesT checkpointCreationAttributes = {
|
|
|
};
|
|
|
|
|
|
SaCkptSectionIdT sectionId1 = {
|
|
|
- "section ID #1",
|
|
|
- 14
|
|
|
+ 14,
|
|
|
+ "section ID #1"
|
|
|
};
|
|
|
|
|
|
SaCkptSectionIdT sectionId2 = {
|
|
|
- "section ID #2",
|
|
|
- 14
|
|
|
+ 14,
|
|
|
+ "section ID #2"
|
|
|
};
|
|
|
+
|
|
|
SaCkptSectionCreationAttributesT sectionCreationAttributes1 = {
|
|
|
§ionId1,
|
|
|
SA_TIME_END
|
|
|
@@ -97,8 +99,8 @@ char readBuffer2[1025];
|
|
|
SaCkptIOVectorElementT ReadVectorElements[] = {
|
|
|
{
|
|
|
{
|
|
|
- "section ID #1",
|
|
|
- 14
|
|
|
+ 14,
|
|
|
+ "section ID #1"
|
|
|
},
|
|
|
readBuffer1,
|
|
|
sizeof (readBuffer1),
|
|
|
@@ -107,8 +109,8 @@ SaCkptIOVectorElementT ReadVectorElements[] = {
|
|
|
},
|
|
|
{
|
|
|
{
|
|
|
- "section ID #2",
|
|
|
- 14
|
|
|
+ 14,
|
|
|
+ "section ID #2"
|
|
|
},
|
|
|
readBuffer2,
|
|
|
sizeof (readBuffer2),
|
|
|
@@ -122,8 +124,8 @@ char data[DATASIZE];
|
|
|
SaCkptIOVectorElementT WriteVectorElements[] = {
|
|
|
{
|
|
|
{
|
|
|
- "section ID #1",
|
|
|
- 14
|
|
|
+ 14,
|
|
|
+ "section ID #1"
|
|
|
},
|
|
|
data, /*"written data #1, this should extend past end of old section data", */
|
|
|
DATASIZE, /*sizeof ("data #1, this should extend past end of old section data") + 1, */
|
|
|
@@ -133,8 +135,8 @@ SaCkptIOVectorElementT WriteVectorElements[] = {
|
|
|
#ifdef COMPILE_OUT
|
|
|
{
|
|
|
{
|
|
|
- "section ID #2",
|
|
|
14
|
|
|
+ "section ID #2",
|
|
|
},
|
|
|
data, /*"written data #2, this should extend past end of old section data" */
|
|
|
DATASIZE, /*sizeof ("written data #2, this should extend past end of old section data") + 1, */
|
|
|
@@ -144,12 +146,18 @@ SaCkptIOVectorElementT WriteVectorElements[] = {
|
|
|
#endif
|
|
|
};
|
|
|
|
|
|
+SaCkptCallbacksT callbacks = {
|
|
|
+ 0,
|
|
|
+ 0
|
|
|
+};
|
|
|
+
|
|
|
int main (void) {
|
|
|
+ SaCkptHandleT ckptHandle;
|
|
|
SaCkptCheckpointHandleT checkpointHandle;
|
|
|
SaCkptCheckpointHandleT checkpointHandle2;
|
|
|
SaCkptCheckpointHandleT checkpointHandleRead;
|
|
|
- SaCkptCheckpointStatusT checkpointStatus;
|
|
|
- SaCkptSectionIteratorT sectionIterator;
|
|
|
+ SaCkptCheckpointDescriptorT checkpointStatus;
|
|
|
+ SaCkptSectionIterationHandleT sectionIterator;
|
|
|
SaCkptSectionDescriptorT sectionDescriptor;
|
|
|
SaUint32T erroroneousVectorIndex = 0;
|
|
|
SaErrorT error;
|
|
|
@@ -157,30 +165,39 @@ int main (void) {
|
|
|
struct timeval tv_end;
|
|
|
struct timeval tv_elapsed;
|
|
|
|
|
|
- error = saCkptCheckpointOpen (&checkpointName,
|
|
|
+ error = saCkptInitialize (&ckptHandle, &callbacks, &version);
|
|
|
+
|
|
|
+ error = saCkptCheckpointOpen (ckptHandle,
|
|
|
+ &checkpointName,
|
|
|
&checkpointCreationAttributes,
|
|
|
SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE,
|
|
|
0,
|
|
|
&checkpointHandle);
|
|
|
- printf ("first open result %d (should be 1)\n", error);
|
|
|
+ printf ("%s: initial open of checkpoint\n",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
|
|
|
gettimeofday (&tv_start, 0);
|
|
|
sectionCreationAttributes1.expirationTime = ((unsigned long long)(tv_start.tv_sec + SECONDS_TO_EXPIRE)) * ((unsigned long long)1000000000) + ((unsigned long long)(tv_start.tv_usec) * ((unsigned long long)1000));
|
|
|
|
|
|
- error = saCkptSectionCreate (&checkpointHandle,
|
|
|
+ error = saCkptSectionCreate (checkpointHandle,
|
|
|
§ionCreationAttributes1,
|
|
|
"Initial Data #0",
|
|
|
strlen ("Initial Data #0") + 1);
|
|
|
+
|
|
|
+ printf ("%s: checkpoint section create\n",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
+
|
|
|
if (error != SA_OK) {
|
|
|
- error = saCkptSectionExpirationTimeSet (&checkpointHandle,
|
|
|
+ error = saCkptSectionExpirationTimeSet (checkpointHandle,
|
|
|
§ionId1,
|
|
|
sectionCreationAttributes1.expirationTime);
|
|
|
+ printf ("%s: checkpoint section expiration set\n",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
}
|
|
|
|
|
|
-printf ("create1 error is %d\n", error);
|
|
|
printf ("Please wait, testing expiry of checkpoint sections.\n");
|
|
|
do {
|
|
|
- error = saCkptCheckpointRead (&checkpointHandle,
|
|
|
+ error = saCkptCheckpointRead (checkpointHandle,
|
|
|
ReadVectorElements,
|
|
|
1,
|
|
|
&erroroneousVectorIndex);
|
|
|
@@ -189,15 +206,18 @@ printf ("Please wait, testing expiry of checkpoint sections.\n");
|
|
|
timersub (&tv_end, &tv_start, &tv_elapsed);
|
|
|
printf ("Elapsed Time to expiry is %ld.%ld (should be about %d seconds)\n", tv_elapsed.tv_sec, tv_elapsed.tv_usec, SECONDS_TO_EXPIRE);
|
|
|
|
|
|
- error = saCkptCheckpointRetentionDurationSet (&checkpointHandle,
|
|
|
+ error = saCkptCheckpointRetentionDurationSet (checkpointHandle,
|
|
|
5000000000LL);
|
|
|
- printf ("RetentionDurationSet is %d\n", error);
|
|
|
+ printf ("%s: RetentionDurationSet\n",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
|
|
|
- error = saCkptSectionCreate (&checkpointHandle,
|
|
|
+ error = saCkptSectionCreate (checkpointHandle,
|
|
|
§ionCreationAttributes2,
|
|
|
"Initial Data #0",
|
|
|
strlen ("Initial Data #0") + 1);
|
|
|
-printf ("create2 error is %d\n", error);
|
|
|
+
|
|
|
+ printf ("%s: Section creation\n",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
printf ("saCkptSectionCreate result %d (should be 1)\n", error);
|
|
|
#ifdef cmpout
|
|
|
for (ckptinv = 0; ckptinv < 500000; ckptinv++) {
|
|
|
@@ -205,7 +225,7 @@ printf ("Writing checkpoint loop %d\n", ckptinv);
|
|
|
/*
|
|
|
* Test checkpoint write
|
|
|
*/
|
|
|
- error = saCkptCheckpointWrite (&checkpointHandle,
|
|
|
+ error = saCkptCheckpointWrite (checkpointHandle,
|
|
|
WriteVectorElements,
|
|
|
1,
|
|
|
&erroroneousVectorIndex);
|
|
|
@@ -217,115 +237,131 @@ if (error != SA_OK) {
|
|
|
exit (1);
|
|
|
#endif
|
|
|
|
|
|
- error = saCkptCheckpointUnlink (&checkpointName);
|
|
|
- printf ("unlink result %d (should be 1)\n", error);
|
|
|
+ error = saCkptCheckpointUnlink (ckptHandle, &checkpointName);
|
|
|
+ printf ("%s: Unlinking checkpoint\n",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
|
|
|
- error = saCkptCheckpointOpen (&checkpointName,
|
|
|
+ error = saCkptCheckpointOpen (ckptHandle,
|
|
|
+ &checkpointName,
|
|
|
&checkpointCreationAttributes,
|
|
|
SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE,
|
|
|
0,
|
|
|
&checkpointHandle2);
|
|
|
- printf ("open after unlink result %d (should be 7)\n", error);
|
|
|
+ printf ("%s: Opening unlinked checkpoint\n",
|
|
|
+ get_test_output (error, 7));
|
|
|
|
|
|
- error = saCkptCheckpointClose (&checkpointHandle);
|
|
|
- printf ("close result %d (should be 1)\n", error);
|
|
|
+ error = saCkptCheckpointClose (checkpointHandle);
|
|
|
+ printf ("%s: Closing checkpoint\n",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
|
|
|
- error = saCkptCheckpointOpen (&checkpointName,
|
|
|
+ error = saCkptCheckpointOpen (ckptHandle,
|
|
|
+ &checkpointName,
|
|
|
&checkpointCreationAttributes,
|
|
|
SA_CKPT_CHECKPOINT_READ,
|
|
|
0,
|
|
|
&checkpointHandleRead);
|
|
|
- printf ("read only open result %d (should be 1)\n", error);
|
|
|
|
|
|
- error = saCkptCheckpointOpen (&checkpointName,
|
|
|
+ printf ("%s: Open checkpoint read only\n",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
+
|
|
|
+
|
|
|
+ error = saCkptCheckpointOpen (ckptHandle,
|
|
|
+ &checkpointName,
|
|
|
&checkpointCreationAttributes,
|
|
|
SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE,
|
|
|
0,
|
|
|
&checkpointHandle);
|
|
|
- printf ("open after unlink/close result %d (should be 1)\n", error);
|
|
|
+ printf ("%s: open after unlink/close\n",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
|
|
|
- error = saCkptCheckpointRetentionDurationSet (&checkpointHandle,
|
|
|
+ error = saCkptCheckpointRetentionDurationSet (checkpointHandle,
|
|
|
5000000000LL);
|
|
|
-printf ("Retention duration set error is %d\n", error);
|
|
|
- printf ("set checkpoint retention duration result %d (should be 1)\n", error);
|
|
|
+ printf ("%s: set checkpoint retention duration\n",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
|
|
|
- error = saCkptCheckpointStatusGet (&checkpointHandle,
|
|
|
+ error = saCkptCheckpointStatusGet (checkpointHandle,
|
|
|
&checkpointStatus);
|
|
|
- printf ("saCkptCheckpointStatusGet result %d (should be 1)\n", error);
|
|
|
+ printf ("%s: Get checkpoint status\n",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
if (error == SA_OK) {
|
|
|
printf ("Memory used %d in %d sections.\n", (int)checkpointStatus.memoryUsed,
|
|
|
(int)checkpointStatus.numberOfSections);
|
|
|
}
|
|
|
|
|
|
- error = saCkptSectionCreate (&checkpointHandleRead,
|
|
|
+ error = saCkptSectionCreate (checkpointHandleRead,
|
|
|
§ionCreationAttributes1,
|
|
|
"Initial Data #0",
|
|
|
strlen ("Initial Data #0") + 1);
|
|
|
- printf ("saCkptSectionCreate result %d (should be 11)\n", error);
|
|
|
+ printf ("%s: Create checkpoint section on read only checkpoint\n",
|
|
|
+ get_test_output (error, SA_AIS_ERR_ACCESS));
|
|
|
|
|
|
- error = saCkptSectionCreate (&checkpointHandle,
|
|
|
+ error = saCkptSectionCreate (checkpointHandle,
|
|
|
§ionCreationAttributes1,
|
|
|
"Initial Data #0",
|
|
|
strlen ("Initial Data #0") + 1);
|
|
|
- printf ("saCkptSectionCreate result %d (should be 1)\n", error);
|
|
|
+ printf ("%s: Create checkpoint section on writeable checkpoint\n",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
|
|
|
- error = saCkptSectionCreate (&checkpointHandle,
|
|
|
+ error = saCkptSectionCreate (checkpointHandle,
|
|
|
§ionCreationAttributes1,
|
|
|
"Initial Data #0",
|
|
|
strlen ("Initial Data #0") + 1);
|
|
|
- printf ("saCkptSectionCreate result %d (should be 14)\n", error);
|
|
|
+ printf ("%s: Create checkpoint section when one already exists\n",
|
|
|
+ get_test_output (error, 14));
|
|
|
|
|
|
-#ifdef COMPILE_OUT
|
|
|
- error = saCkptSectionDelete (&checkpointHandle,
|
|
|
+ error = saCkptSectionDelete (checkpointHandle,
|
|
|
§ionId1);
|
|
|
- printf ("saCkptSectionDelete result %d (should be 1)\n", error);
|
|
|
+ printf ("%s: deleting checkpoint handle\n",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
|
|
|
- error = saCkptSectionCreate (&checkpointHandle,
|
|
|
+ error = saCkptSectionCreate (checkpointHandle,
|
|
|
§ionCreationAttributes1,
|
|
|
"Initial Data #0",
|
|
|
strlen ("Initial Data #0") + 1);
|
|
|
- printf ("saCkptSectionCreate result %d (should be 1)\n", error);
|
|
|
-#endif
|
|
|
+ printf ("%s: replacing deleted checkpoint section\n",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
|
|
|
- error = saCkptSectionExpirationTimeSet (&checkpointHandle,
|
|
|
+ error = saCkptSectionExpirationTimeSet (checkpointHandle,
|
|
|
§ionId2,
|
|
|
SA_TIME_END);
|
|
|
- printf ("saCkptSectionExpirationTimeSet result %d (should be 1)\n", error);
|
|
|
+ printf ("%s: Setting expiration time for section 2\n",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
|
|
|
-
|
|
|
- error = saCkptSectionOverwrite (&checkpointHandle,
|
|
|
+ error = saCkptSectionOverwrite (checkpointHandle,
|
|
|
§ionId1,
|
|
|
"Overwrite Data #1",
|
|
|
strlen ("Overwrite Data #1") + 1);
|
|
|
- printf ("saCkptSectionOverwrite result %d (should be 1)\n", error);
|
|
|
+ printf ("%s: overwriting checkpoint section 1\n",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
|
|
|
/*
|
|
|
* Test checkpoint read
|
|
|
*/
|
|
|
memset (readBuffer1, 0, sizeof (readBuffer1));
|
|
|
memset (readBuffer2, 0, sizeof (readBuffer2));
|
|
|
- error = saCkptSectionCreate (&checkpointHandle,
|
|
|
+ error = saCkptSectionCreate (checkpointHandle,
|
|
|
§ionCreationAttributes2,
|
|
|
"Initial Data #2",
|
|
|
strlen ("Initial Data #2") + 1);
|
|
|
- printf ("saCkptSectionCreate result %d (should be 1)\n", error);
|
|
|
+ printf ("%s: creating checkpoint for read test\n",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
|
|
|
- error = saCkptCheckpointRead (&checkpointHandle,
|
|
|
+ error = saCkptCheckpointRead (checkpointHandle,
|
|
|
ReadVectorElements,
|
|
|
2,
|
|
|
&erroroneousVectorIndex);
|
|
|
- printf ("saCkptCheckpointRead result %d (should be 1)\n", error);
|
|
|
+ printf ("%s: checkpoint read operation",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
printf ("Buffers after checkpoint read\n");
|
|
|
printf (" buffer #1: '%s'\n", readBuffer1);
|
|
|
printf (" buffer #2: '%s'\n", readBuffer2);
|
|
|
|
|
|
-//sleep (20);
|
|
|
#ifdef COMPILE_OUT
|
|
|
for (ckptinv = 0; ckptinv < 2000; ckptinv++) {
|
|
|
/*
|
|
|
* Test checkpoint write
|
|
|
*/
|
|
|
- error = saCkptCheckpointWrite (&checkpointHandle,
|
|
|
+ error = saCkptCheckpointWrite (checkpointHandle,
|
|
|
WriteVectorElements,
|
|
|
2,
|
|
|
&erroroneousVectorIndex);
|
|
|
@@ -337,7 +373,7 @@ exit (1);
|
|
|
}
|
|
|
exit (1);
|
|
|
#endif
|
|
|
- error = saCkptCheckpointRead (&checkpointHandle,
|
|
|
+ error = saCkptCheckpointRead (checkpointHandle,
|
|
|
ReadVectorElements,
|
|
|
2,
|
|
|
&erroroneousVectorIndex);
|
|
|
@@ -346,26 +382,30 @@ exit (1);
|
|
|
// printf (" buffer #1: '%s'\n", readBuffer1);
|
|
|
// printf (" buffer #2: '%s'\n", readBuffer2);
|
|
|
|
|
|
- error = saCkptCheckpointStatusGet (&checkpointHandle,
|
|
|
+ error = saCkptCheckpointStatusGet (checkpointHandle,
|
|
|
&checkpointStatus);
|
|
|
- printf ("saCkptCheckpointStatusGet result %d (should be 1)\n", error);
|
|
|
+ printf ("%s: get checkpoint status\n",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
if (error == SA_OK) {
|
|
|
- printf ("Memory used %d in %d sections.\n", (int)checkpointStatus.memoryUsed,
|
|
|
+ printf ("Memory used %d in %d sections.\n",
|
|
|
+ (int)checkpointStatus.memoryUsed,
|
|
|
(int)checkpointStatus.numberOfSections);
|
|
|
}
|
|
|
- error = saCkptSectionIteratorInitialize (&checkpointHandle,
|
|
|
+ error = saCkptSectionIterationInitialize (checkpointHandle,
|
|
|
0,
|
|
|
0,
|
|
|
§ionIterator);
|
|
|
- printf ("saCkptSectionIteratorInitialize result %d (should be 1)\n", error);
|
|
|
+ printf ("%s: initialize section iterator\n",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
|
|
|
/*
|
|
|
* Iterate all sections
|
|
|
*/
|
|
|
do {
|
|
|
- error = saCkptSectionIteratorNext (§ionIterator,
|
|
|
+ error = saCkptSectionIterationNext (sectionIterator,
|
|
|
§ionDescriptor);
|
|
|
- printf ("saCkptSectionIteratorNext result %d (should be 1)\n", error);
|
|
|
+ printf ("%s: Get next section in iteartion\n",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
if (error == SA_OK) {
|
|
|
printf ("Section '%s' expires %llx size %d state %x update %llx\n",
|
|
|
sectionDescriptor.sectionId.id,
|
|
|
@@ -375,8 +415,10 @@ exit (1);
|
|
|
sectionDescriptor.lastUpdate);
|
|
|
}
|
|
|
} while (error == SA_OK);
|
|
|
+ printf ("The last iteration should fail\n");
|
|
|
|
|
|
- error = saCkptSectionIteratorFinalize (§ionIterator);
|
|
|
- printf ("saCkptSectionIteratorFinalize result %d (should be 1)\n", error);
|
|
|
+ error = saCkptSectionIterationFinalize (sectionIterator);
|
|
|
+ printf ("%s: Finalize iteration\n",
|
|
|
+ get_test_output (error, SA_AIS_OK));
|
|
|
return (0);
|
|
|
}
|