Просмотр исходного кода

Increase code coverage by calling more API functions.

(Logical change 1.136)


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@491 fd59a12c-fef9-0310-b244-a6a79926bd2f
Steven Dake 21 лет назад
Родитель
Сommit
eee52e30ce
2 измененных файлов с 29 добавлено и 32 удалено
  1. 23 32
      test/testckpt.c
  2. 6 0
      test/testevs.c

+ 23 - 32
test/testckpt.c

@@ -164,6 +164,7 @@ int main (void) {
 	struct timeval tv_start;
 	struct timeval tv_end;
 	struct timeval tv_elapsed;
+	int sel_fd;
 	
     error = saCkptInitialize (&ckptHandle, &callbacks, &version);
 	
@@ -218,24 +219,6 @@ printf ("Please wait, testing expiry of checkpoint sections.\n");
 
 	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++) {
-printf ("Writing checkpoint loop %d\n", ckptinv);
-	/*
-	 * Test checkpoint write
-	 */
-	error = saCkptCheckpointWrite (checkpointHandle,
-		WriteVectorElements,
-		1,
-		&erroroneousVectorIndex);
-if (error != SA_OK) {
-	printf ("saCkptCheckpointWrite result %d (should be 1)\n", error);
-	exit (1);
-}
-}
-exit (1);
-#endif
 
 	error = saCkptCheckpointUnlink (ckptHandle, &checkpointName);
 	printf ("%s: Unlinking checkpoint\n", 
@@ -356,23 +339,22 @@ exit (1);
 	printf (" buffer #1: '%s'\n", readBuffer1);
 	printf (" buffer #2: '%s'\n", readBuffer2);
 
-#ifdef COMPILE_OUT
-for (ckptinv = 0; ckptinv < 2000; ckptinv++) {
+	for (ckptinv = 0; ckptinv < 10; ckptinv++) {
 	/*
 	 * Test checkpoint write
 	 */
-	error = saCkptCheckpointWrite (checkpointHandle,
-		WriteVectorElements,
-		2,
-		&erroroneousVectorIndex);
-if (error != SA_OK) {
-printf ("Writing checkpoint loop %d\n", ckptinv);
-	printf ("saCkptCheckpointWrite result %d (should be 1)\n", error);
-exit (1);
-}
-}
-exit (1);
-#endif
+		error = saCkptCheckpointWrite (checkpointHandle,
+			WriteVectorElements,
+			2,
+			&erroroneousVectorIndex);
+		if (error != SA_OK) {
+			printf ("Writing checkpoint loop %d\n", ckptinv);
+				printf ("saCkptCheckpointWrite result %d (should be 1)\n", error);
+		}
+	}
+	printf ("%s: Testing checkpoint writes\n",
+		get_test_output (error, SA_AIS_OK));
+
 	error = saCkptCheckpointRead (checkpointHandle,
 		ReadVectorElements,
 		2,
@@ -420,5 +402,14 @@ exit (1);
 	error = saCkptSectionIterationFinalize (sectionIterator);
 	printf ("%s: Finalize iteration\n",
 		get_test_output (error, SA_AIS_OK));
+
+	error = saCkptSelectionObjectGet (ckptHandle, &sel_fd);
+	printf ("%s: Retrieve selection object %d\n",
+		get_test_output (error, SA_AIS_OK), sel_fd);
+
+	error = saCkptFinalize (ckptHandle);
+	printf ("%s: Finalize checkpoint\n",
+		get_test_output (error, SA_AIS_OK));
+
 	return (0);
 }

+ 6 - 0
test/testevs.c

@@ -97,6 +97,7 @@ int main (void)
 	evs_handle_t handle;
 	evs_error_t result;
 	int i = 0;
+	int fd;
 
 	result = evs_initialize (&handle, &callbacks);
 	if (result != EVS_OK) {
@@ -154,5 +155,10 @@ try_again_two:
 	do {
 		result = evs_dispatch (&handle, EVS_DISPATCH_ALL);
 	} while (deliveries < 900);
+
+	evs_fd_get (&handle, &fd);
+	
+	evs_finalize (&handle);
+
 	return (0);
 }