summaryrefslogtreecommitdiffstats
path: root/common/test_textfile.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2006-02-07 09:10:07 +0000
committerMarcel Holtmann <marcel@holtmann.org>2006-02-07 09:10:07 +0000
commit71dc4067220c5b994885f63127b4b7eb947002fd (patch)
tree993e1bcb31145dd26f525be0028ce142ce29f72a /common/test_textfile.c
parentb7d130c68efdeea62d459e5c6c968c89412d9f46 (diff)
Add support for deleting keys
Diffstat (limited to 'common/test_textfile.c')
-rw-r--r--common/test_textfile.c86
1 files changed, 84 insertions, 2 deletions
diff --git a/common/test_textfile.c b/common/test_textfile.c
index 80761526..c2b2c993 100644
--- a/common/test_textfile.c
+++ b/common/test_textfile.c
@@ -38,12 +38,13 @@ int main(int argc, char *argv[])
{
char filename[] = "/tmp/textfile";
char key[18], value[512], *str;
- int i, j, fd;
+ int i, j, fd, max = 10;
fd = creat(filename, 0644);
close(fd);
- for (i = 1; i < 101; i++) {
+
+ for (i = 1; i < max + 1; i++) {
sprintf(key, "00:00:00:00:00:%02X", i);
memset(value, 0, sizeof(value));
@@ -64,5 +65,86 @@ int main(int argc, char *argv[])
free(str);
}
+
+ sprintf(key, "00:00:00:00:00:%02X", max);
+
+ memset(value, 0, sizeof(value));
+ for (j = 0; j < max; j++)
+ value[j] = 'y';
+
+ if (textfile_put(filename, key, value) < 0)
+ fprintf(stderr, "%s (%d)\n", strerror(errno), errno);
+
+ sprintf(key, "00:00:00:00:00:%02X", 1);
+
+ memset(value, 0, sizeof(value));
+ for (j = 0; j < max; j++)
+ value[j] = 'z';
+
+ if (textfile_put(filename, key, value) < 0)
+ fprintf(stderr, "%s (%d)\n", strerror(errno), errno);
+
+ printf("\n");
+
+ for (i = 1; i < max + 1; i++) {
+ sprintf(key, "00:00:00:00:00:%02X", i);
+
+ str = textfile_get(filename, key);
+ if (str) {
+ printf("%s %s\n", key, str);
+ free(str);
+ }
+ }
+
+
+ sprintf(key, "00:00:00:00:00:%02X", 2);
+
+ if (textfile_del(filename, key) < 0)
+ fprintf(stderr, "%s (%d)\n", strerror(errno), errno);
+
+ sprintf(key, "00:00:00:00:00:%02X", max - 3);
+
+ if (textfile_del(filename, key) < 0)
+ fprintf(stderr, "%s (%d)\n", strerror(errno), errno);
+
+ printf("\n");
+
+ for (i = 1; i < max + 1; i++) {
+ sprintf(key, "00:00:00:00:00:%02X", i);
+
+ str = textfile_get(filename, key);
+ if (str) {
+ printf("%s %s\n", key, str);
+ free(str);
+ }
+ }
+
+ sprintf(key, "00:00:00:00:00:%02X", 1);
+
+ if (textfile_del(filename, key) < 0)
+ fprintf(stderr, "%s (%d)\n", strerror(errno), errno);
+
+ sprintf(key, "00:00:00:00:00:%02X", max);
+
+ if (textfile_del(filename, key) < 0)
+ fprintf(stderr, "%s (%d)\n", strerror(errno), errno);
+
+ sprintf(key, "00:00:00:00:00:%02X", max + 1);
+
+ if (textfile_del(filename, key) < 0)
+ fprintf(stderr, "%s (%d)\n", strerror(errno), errno);
+
+ printf("\n");
+
+ for (i = 1; i < max + 1; i++) {
+ sprintf(key, "00:00:00:00:00:%02X", i);
+
+ str = textfile_get(filename, key);
+ if (str) {
+ printf("%s %s\n", key, str);
+ free(str);
+ }
+ }
+
return 0;
}