change to test new copyHeader code
authorroot <devnull@localhost>
Thu, 15 Feb 1996 22:44:04 +0000 (22:44 +0000)
committerroot <devnull@localhost>
Thu, 15 Feb 1996 22:44:04 +0000 (22:44 +0000)
CVS patchset: 288
CVS date: 1996/02/15 22:44:04

lib/test.c

index cc94336..8910413 100644 (file)
@@ -1,13 +1,15 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+
 #include "header.h"
 #include "rpmlib.h"
 
-#include <string.h>
-
 void main(int argc, char **argv)
 {
-#if 0
-    Header h;
-    FILE *f;
+    Header h, h2, h3, h4;
+    int fd;
     char *sa[] = {"one", "two", "three"};
     int_32 i32 = 400;
     int_32 i32a[] = {100, 200, 300};
@@ -19,19 +21,39 @@ void main(int argc, char **argv)
 
     addEntry(h, RPMTAG_NAME, STRING_TYPE, "MarcEwing", 1);
     addEntry(h, RPMTAG_VERSION, STRING_TYPE, "1.1", 1);
-    addEntry(h, RPMTAG_VERSION, STRING_TYPE, sa, 3);
+    addEntry(h, RPMTAG_VERSION, STRING_ARRAY_TYPE, sa, 3);
     addEntry(h, RPMTAG_SIZE, INT32_TYPE, &i32, 1);
     addEntry(h, RPMTAG_SIZE, INT16_TYPE, &i16, 1);
     addEntry(h, RPMTAG_SIZE, INT16_TYPE, i16a, 3);
     addEntry(h, RPMTAG_VENDOR, CHAR_TYPE, ca, strlen(ca));
     addEntry(h, RPMTAG_SIZE, INT32_TYPE, i32a, 3);
 
-    f = fopen("test.out", "w");
-    writeHeader(f, h);
-    fclose(f);
+    printf("Original = %d\n", sizeofHeader(h));
+    fd = open("test.out", O_WRONLY|O_CREAT);
+    writeHeader(fd, h);
+    close(fd);
+    h2 = copyHeader(h);
+    printf("Copy     = %d\n", sizeofHeader(h2));
 
+    fd = open("test.out", O_RDONLY);
+    h3 = readHeader(fd);
+    close(fd);
+   
+    printf("From disk    = %d\n", sizeofHeader(h3));
+    h4 = copyHeader(h3);
+    printf("Copy of disk = %d\n", sizeofHeader(h4));
+   
+    printf("=====================\n");
+    printf("Original\n");
     dumpHeader(h, stdout, 1);
-#endif
+    printf("=====================\n");
+    printf("From disk\n");
+    dumpHeader(h3, stdout, 1);
+    printf("=====================\n");
+    printf("Copy of disk\n");
+    dumpHeader(h4, stdout, 1);
 
+#if 0
     convertDB("");
+#endif
 }