summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/vlog-modules.def2
-rw-r--r--ovsdb/automake.mk4
-rw-r--r--ovsdb/execution.c8
-rw-r--r--ovsdb/log.c (renamed from ovsdb/file.c)43
-rw-r--r--ovsdb/log.h (renamed from ovsdb/file.h)20
-rw-r--r--ovsdb/ovsdb-tool.c14
-rw-r--r--ovsdb/ovsdb.c20
-rw-r--r--ovsdb/ovsdb.h4
-rw-r--r--tests/automake.mk2
-rw-r--r--tests/ovsdb-log.at (renamed from tests/ovsdb-file.at)102
-rw-r--r--tests/ovsdb.at2
-rw-r--r--tests/test-ovsdb.c24
12 files changed, 124 insertions, 121 deletions
diff --git a/lib/vlog-modules.def b/lib/vlog-modules.def
index 5dc774585..24f62cc67 100644
--- a/lib/vlog-modules.def
+++ b/lib/vlog-modules.def
@@ -56,7 +56,7 @@ VLOG_MODULE(ofproto)
VLOG_MODULE(openflowd)
VLOG_MODULE(ovsdb)
VLOG_MODULE(ovsdb_client)
-VLOG_MODULE(ovsdb_file)
+VLOG_MODULE(ovsdb_log)
VLOG_MODULE(ovsdb_jsonrpc_server)
VLOG_MODULE(ovsdb_server)
VLOG_MODULE(ovsdb_tool)
diff --git a/ovsdb/automake.mk b/ovsdb/automake.mk
index 04fa52da1..b996a306f 100644
--- a/ovsdb/automake.mk
+++ b/ovsdb/automake.mk
@@ -6,10 +6,10 @@ ovsdb_libovsdb_a_SOURCES = \
ovsdb/condition.c \
ovsdb/condition.h \
ovsdb/execution.c \
- ovsdb/file.c \
- ovsdb/file.h \
ovsdb/jsonrpc-server.c \
ovsdb/jsonrpc-server.h \
+ ovsdb/log.c \
+ ovsdb/log.h \
ovsdb/ovsdb-server.c \
ovsdb/ovsdb.c \
ovsdb/ovsdb.h \
diff --git a/ovsdb/execution.c b/ovsdb/execution.c
index f3e917260..6bad67c2b 100644
--- a/ovsdb/execution.c
+++ b/ovsdb/execution.c
@@ -20,8 +20,8 @@
#include "column.h"
#include "condition.h"
-#include "file.h"
#include "json.h"
+#include "log.h"
#include "ovsdb-data.h"
#include "ovsdb-error.h"
#include "ovsdb-parser.h"
@@ -211,7 +211,7 @@ ovsdb_execute_abort(struct ovsdb_execution *x UNUSED,
static struct ovsdb_error *
do_commit(struct ovsdb_execution *x)
{
- if (x->db->file) {
+ if (x->db->log) {
struct ovsdb_error *error;
struct json *json;
@@ -221,14 +221,14 @@ do_commit(struct ovsdb_execution *x)
return NULL;
}
- error = ovsdb_file_write(x->db->file, json);
+ error = ovsdb_log_write(x->db->log, json);
json_destroy(json);
if (error) {
return ovsdb_wrap_error(error, "writing transaction failed");
}
if (x->durable) {
- error = ovsdb_file_commit(x->db->file);
+ error = ovsdb_log_commit(x->db->log);
if (error) {
return ovsdb_wrap_error(error,
"committing transaction failed");
diff --git a/ovsdb/file.c b/ovsdb/log.c
index 4883d76f1..9c2e277ce 100644
--- a/ovsdb/file.c
+++ b/ovsdb/log.c
@@ -15,7 +15,7 @@
#include <config.h>
-#include "file.h"
+#include "log.h"
#include <assert.h>
#include <errno.h>
@@ -26,34 +26,36 @@
#include "json.h"
#include "lockfile.h"
+#include "ovsdb.h"
#include "ovsdb-error.h"
#include "sha1.h"
+#include "transaction.h"
#include "util.h"
-#define THIS_MODULE VLM_ovsdb_file
+#define THIS_MODULE VLM_ovsdb_log
#include "vlog.h"
-enum ovsdb_file_mode {
- OVSDB_FILE_READ,
- OVSDB_FILE_WRITE
+enum ovsdb_log_mode {
+ OVSDB_LOG_READ,
+ OVSDB_LOG_WRITE
};
-struct ovsdb_file {
+struct ovsdb_log {
off_t offset;
char *name;
struct lockfile *lockfile;
FILE *stream;
struct ovsdb_error *read_error;
struct ovsdb_error *write_error;
- enum ovsdb_file_mode mode;
+ enum ovsdb_log_mode mode;
};
struct ovsdb_error *
-ovsdb_file_open(const char *name, int flags, struct ovsdb_file **filep)
+ovsdb_log_open(const char *name, int flags, struct ovsdb_log **filep)
{
struct lockfile *lockfile;
struct ovsdb_error *error;
- struct ovsdb_file *file;
+ struct ovsdb_log *file;
struct stat s;
FILE *stream;
int accmode;
@@ -111,7 +113,7 @@ ovsdb_file_open(const char *name, int flags, struct ovsdb_file **filep)
file->offset = 0;
file->read_error = NULL;
file->write_error = NULL;
- file->mode = OVSDB_FILE_READ;
+ file->mode = OVSDB_LOG_READ;
*filep = file;
return NULL;
@@ -124,7 +126,7 @@ error:
}
void
-ovsdb_file_close(struct ovsdb_file *file)
+ovsdb_log_close(struct ovsdb_log *file)
{
if (file) {
free(file->name);
@@ -170,15 +172,15 @@ parse_header(char *header, unsigned long int *length,
return true;
}
-struct ovsdb_file_read_cbdata {
+struct ovsdb_log_read_cbdata {
char input[4096];
- struct ovsdb_file *file;
+ struct ovsdb_log *file;
int error;
unsigned long length;
};
static struct ovsdb_error *
-parse_body(struct ovsdb_file *file, off_t offset, unsigned long int length,
+parse_body(struct ovsdb_log *file, off_t offset, unsigned long int length,
uint8_t sha1[SHA1_DIGEST_SIZE], struct json **jsonp)
{
unsigned long int bytes_left;
@@ -212,7 +214,7 @@ parse_body(struct ovsdb_file *file, off_t offset, unsigned long int length,
}
struct ovsdb_error *
-ovsdb_file_read(struct ovsdb_file *file, struct json **jsonp)
+ovsdb_log_read(struct ovsdb_log *file, struct json **jsonp)
{
uint8_t expected_sha1[SHA1_DIGEST_SIZE];
uint8_t actual_sha1[SHA1_DIGEST_SIZE];
@@ -226,7 +228,7 @@ ovsdb_file_read(struct ovsdb_file *file, struct json **jsonp)
if (file->read_error) {
return ovsdb_error_clone(file->read_error);
- } else if (file->mode == OVSDB_FILE_WRITE) {
+ } else if (file->mode == OVSDB_LOG_WRITE) {
return OVSDB_BUG("reading file in write mode");
}
@@ -284,7 +286,7 @@ error:
}
struct ovsdb_error *
-ovsdb_file_write(struct ovsdb_file *file, struct json *json)
+ovsdb_log_write(struct ovsdb_log *file, struct json *json)
{
uint8_t sha1[SHA1_DIGEST_SIZE];
struct ovsdb_error *error;
@@ -296,8 +298,8 @@ ovsdb_file_write(struct ovsdb_file *file, struct json *json)
if (file->write_error) {
return ovsdb_error_clone(file->write_error);
- } else if (file->mode == OVSDB_FILE_READ) {
- file->mode = OVSDB_FILE_WRITE;
+ } else if (file->mode == OVSDB_LOG_READ) {
+ file->mode = OVSDB_LOG_WRITE;
if (fseeko(file->stream, file->offset, SEEK_SET)) {
error = ovsdb_io_error(errno, "%s: cannot seek to offset %lld",
file->name, (long long int) file->offset);
@@ -351,10 +353,11 @@ error:
}
struct ovsdb_error *
-ovsdb_file_commit(struct ovsdb_file *file)
+ovsdb_log_commit(struct ovsdb_log *file)
{
if (fsync(fileno(file->stream))) {
return ovsdb_io_error(errno, "%s: fsync failed", file->name);
}
return 0;
}
+
diff --git a/ovsdb/file.h b/ovsdb/log.h
index 5178140a1..2daa635ba 100644
--- a/ovsdb/file.h
+++ b/ovsdb/log.h
@@ -13,24 +13,24 @@
* limitations under the License.
*/
-#ifndef OVSDB_FILE_H
-#define OVSDB_FILE_H 1
+#ifndef OVSDB_LOG_H
+#define OVSDB_LOG_H 1
#include <sys/types.h>
#include "compiler.h"
struct json;
-struct ovsdb_file;
+struct ovsdb_log;
-struct ovsdb_error *ovsdb_file_open(const char *name, int flags,
- struct ovsdb_file **) WARN_UNUSED_RESULT;
-void ovsdb_file_close(struct ovsdb_file *);
+struct ovsdb_error *ovsdb_log_open(const char *name, int flags,
+ struct ovsdb_log **) WARN_UNUSED_RESULT;
+void ovsdb_log_close(struct ovsdb_log *);
-struct ovsdb_error *ovsdb_file_read(struct ovsdb_file *, struct json **)
+struct ovsdb_error *ovsdb_log_read(struct ovsdb_log *, struct json **)
WARN_UNUSED_RESULT;
-struct ovsdb_error *ovsdb_file_write(struct ovsdb_file *, struct json *)
+struct ovsdb_error *ovsdb_log_write(struct ovsdb_log *, struct json *)
WARN_UNUSED_RESULT;
-struct ovsdb_error *ovsdb_file_commit(struct ovsdb_file *)
+struct ovsdb_error *ovsdb_log_commit(struct ovsdb_log *)
WARN_UNUSED_RESULT;
-#endif /* ovsdb/file.h */
+#endif /* ovsdb/log.h */
diff --git a/ovsdb/ovsdb-tool.c b/ovsdb/ovsdb-tool.c
index d6e0ff941..8b81ef615 100644
--- a/ovsdb/ovsdb-tool.c
+++ b/ovsdb/ovsdb-tool.c
@@ -24,7 +24,7 @@
#include "command-line.h"
#include "compiler.h"
-#include "file.h"
+#include "log.h"
#include "json.h"
#include "ovsdb.h"
#include "ovsdb-error.h"
@@ -144,7 +144,7 @@ do_create(int argc UNUSED, char *argv[])
const char *db_file_name = argv[1];
const char *schema_file_name = argv[2];
struct ovsdb_schema *schema;
- struct ovsdb_file *db_file;
+ struct ovsdb_log *log;
struct json *json;
/* Read schema from file and convert to JSON. */
@@ -152,11 +152,11 @@ do_create(int argc UNUSED, char *argv[])
json = ovsdb_schema_to_json(schema);
/* Create database file. */
- check_ovsdb_error(ovsdb_file_open(db_file_name, O_RDWR | O_CREAT | O_EXCL,
- &db_file));
- check_ovsdb_error(ovsdb_file_write(db_file, json));
- check_ovsdb_error(ovsdb_file_commit(db_file));
- ovsdb_file_close(db_file);
+ check_ovsdb_error(ovsdb_log_open(db_file_name, O_RDWR | O_CREAT | O_EXCL,
+ &log));
+ check_ovsdb_error(ovsdb_log_write(log, json));
+ check_ovsdb_error(ovsdb_log_commit(log));
+ ovsdb_log_close(log);
json_destroy(json);
}
diff --git a/ovsdb/ovsdb.c b/ovsdb/ovsdb.c
index 6d0f131ea..7caa229da 100644
--- a/ovsdb/ovsdb.c
+++ b/ovsdb/ovsdb.c
@@ -19,7 +19,7 @@
#include <fcntl.h>
-#include "file.h"
+#include "log.h"
#include "json.h"
#include "ovsdb-error.h"
#include "ovsdb-parser.h"
@@ -153,14 +153,14 @@ ovsdb_schema_to_json(const struct ovsdb_schema *schema)
}
struct ovsdb *
-ovsdb_create(struct ovsdb_file *file, struct ovsdb_schema *schema)
+ovsdb_create(struct ovsdb_log *log, struct ovsdb_schema *schema)
{
struct shash_node *node;
struct ovsdb *db;
db = xmalloc(sizeof *db);
db->schema = schema;
- db->file = file;
+ db->log = log;
list_init(&db->triggers);
db->run_triggers = false;
@@ -178,16 +178,16 @@ ovsdb_open(const char *file_name, bool read_only, struct ovsdb **dbp)
{
struct ovsdb_schema *schema;
struct ovsdb_error *error;
- struct ovsdb_file *file;
+ struct ovsdb_log *log;
struct json *json;
struct ovsdb *db;
- error = ovsdb_file_open(file_name, read_only ? O_RDONLY : O_RDWR, &file);
+ error = ovsdb_log_open(file_name, read_only ? O_RDONLY : O_RDWR, &log);
if (error) {
return error;
}
- error = ovsdb_file_read(file, &json);
+ error = ovsdb_log_read(log, &json);
if (error) {
return error;
} else if (!json) {
@@ -204,8 +204,8 @@ ovsdb_open(const char *file_name, bool read_only, struct ovsdb **dbp)
}
json_destroy(json);
- db = ovsdb_create(read_only ? NULL : file, schema);
- while ((error = ovsdb_file_read(file, &json)) == NULL && json) {
+ db = ovsdb_create(read_only ? NULL : log, schema);
+ while ((error = ovsdb_log_read(log, &json)) == NULL && json) {
struct ovsdb_txn *txn;
error = ovsdb_txn_from_json(db, json, &txn);
@@ -225,7 +225,7 @@ ovsdb_open(const char *file_name, bool read_only, struct ovsdb **dbp)
}
if (read_only) {
- ovsdb_file_close(file);
+ ovsdb_log_close(log);
}
*dbp = db;
@@ -251,7 +251,7 @@ ovsdb_destroy(struct ovsdb *db)
shash_clear(&db->schema->tables);
ovsdb_schema_destroy(db->schema);
- ovsdb_file_close(db->file);
+ ovsdb_log_close(db->log);
free(db);
}
}
diff --git a/ovsdb/ovsdb.h b/ovsdb/ovsdb.h
index 3f62966a7..d57ebfca6 100644
--- a/ovsdb/ovsdb.h
+++ b/ovsdb/ovsdb.h
@@ -46,7 +46,7 @@ struct json *ovsdb_schema_to_json(const struct ovsdb_schema *);
/* Database. */
struct ovsdb {
struct ovsdb_schema *schema;
- struct ovsdb_file *file; /* Disk file (null for in-memory db). */
+ struct ovsdb_log *log; /* Disk log (null for in-memory db). */
struct shash tables; /* Contains "struct ovsdb_table *"s. */
/* Triggers. */
@@ -54,7 +54,7 @@ struct ovsdb {
bool run_triggers;
};
-struct ovsdb *ovsdb_create(struct ovsdb_file *, struct ovsdb_schema *);
+struct ovsdb *ovsdb_create(struct ovsdb_log *, struct ovsdb_schema *);
struct ovsdb_error *ovsdb_open(const char *file_name, bool read_only,
struct ovsdb **)
WARN_UNUSED_RESULT;
diff --git a/tests/automake.mk b/tests/automake.mk
index f662d9501..3a54e1339 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -17,7 +17,7 @@ TESTSUITE_AT = \
tests/lockfile.at \
tests/reconnect.at \
tests/ovsdb.at \
- tests/ovsdb-file.at \
+ tests/ovsdb-log.at \
tests/ovsdb-types.at \
tests/ovsdb-data.at \
tests/ovsdb-column.at \
diff --git a/tests/ovsdb-file.at b/tests/ovsdb-log.at
index c85b29e2d..b0c1c97bd 100644
--- a/tests/ovsdb-file.at
+++ b/tests/ovsdb-log.at
@@ -1,90 +1,90 @@
-AT_BANNER([OVSDB -- file I/O])
+AT_BANNER([OVSDB -- logging])
AT_SETUP([create empty, reread])
-AT_KEYWORDS([ovsdb file])
-AT_CAPTURE_FILE([file])
+AT_KEYWORDS([ovsdb log])
+AT_CAPTURE_FILE([log])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_CREAT|O_RDWR'], [0],
+ [test-ovsdb log-io file 'O_CREAT|O_RDWR'], [0],
[file: open successful
], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read], [0],
[file: open successful
-file: read: end of file
+file: read: end of log
], [ignore])
AT_CHECK([test -f .file.~lock~])
AT_CLEANUP
AT_SETUP([write one, reread])
-AT_KEYWORDS([ovsdb file])
+AT_KEYWORDS([ovsdb log])
AT_CAPTURE_FILE([file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_CREAT|O_RDWR' 'write:[0]']], [0],
+ [[test-ovsdb log-io file 'O_CREAT|O_RDWR' 'write:[0]']], [0],
[[file: open successful
file: write:[0] successful
]], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read read], [0],
[[file: open successful
file: read: [0]
-file: read: end of file
+file: read: end of log
]], [ignore])
AT_CHECK([test -f .file.~lock~])
AT_CLEANUP
AT_SETUP([check that O_EXCL works])
-AT_KEYWORDS([ovsdb file])
+AT_KEYWORDS([ovsdb log])
AT_CAPTURE_FILE([file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_CREAT|O_RDWR' 'write:[1]']], [0],
+ [[test-ovsdb log-io file 'O_CREAT|O_RDWR' 'write:[1]']], [0],
[[file: open successful
file: write:[1] successful
]], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read], [0],
[[file: open successful
file: read: [1]
]], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_CREAT|O_RDWR|O_EXCL' read], [1],
+ [test-ovsdb log-io file 'O_CREAT|O_RDWR|O_EXCL' read], [1],
[], [test-ovsdb: I/O error: create: file failed (File exists)
])
AT_CHECK([test -f .file.~lock~])
AT_CLEANUP
AT_SETUP([write one, reread])
-AT_KEYWORDS([ovsdb file])
+AT_KEYWORDS([ovsdb log])
AT_CAPTURE_FILE([file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
+ [[test-ovsdb log-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
[[file: open successful
file: write:[0] successful
file: write:[1] successful
file: write:[2] successful
]], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read read read read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read read read read], [0],
[[file: open successful
file: read: [0]
file: read: [1]
file: read: [2]
-file: read: end of file
+file: read: end of log
]], [ignore])
AT_CHECK([test -f .file.~lock~])
AT_CLEANUP
AT_SETUP([write one, reread, append])
-AT_KEYWORDS([ovsdb file])
+AT_KEYWORDS([ovsdb log])
AT_CAPTURE_FILE([file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
+ [[test-ovsdb log-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
[[file: open successful
file: write:[0] successful
file: write:[1] successful
file: write:[2] successful
]], [ignore])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_RDWR' read read read 'write:["append"]']], [0],
+ [[test-ovsdb log-io file 'O_RDWR' read read read 'write:["append"]']], [0],
[[file: open successful
file: read: [0]
file: read: [1]
@@ -92,48 +92,48 @@ file: read: [2]
file: write:["append"] successful
]], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read read read read read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read read read read read], [0],
[[file: open successful
file: read: [0]
file: read: [1]
file: read: [2]
file: read: ["append"]
-file: read: end of file
+file: read: end of log
]], [ignore])
AT_CHECK([test -f .file.~lock~])
AT_CLEANUP
AT_SETUP([write, reread one, overwrite])
-AT_KEYWORDS([ovsdb file])
+AT_KEYWORDS([ovsdb log])
AT_CAPTURE_FILE([file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
+ [[test-ovsdb log-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
[[file: open successful
file: write:[0] successful
file: write:[1] successful
file: write:[2] successful
]], [ignore])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_RDWR' read 'write:["more data"]']], [0],
+ [[test-ovsdb log-io file 'O_RDWR' read 'write:["more data"]']], [0],
[[file: open successful
file: read: [0]
file: write:["more data"] successful
]], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read read read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read read read], [0],
[[file: open successful
file: read: [0]
file: read: ["more data"]
-file: read: end of file
+file: read: end of log
]], [ignore])
AT_CHECK([test -f .file.~lock~])
AT_CLEANUP
AT_SETUP([write, add corrupted data, read])
-AT_KEYWORDS([ovsdb file])
+AT_KEYWORDS([ovsdb log])
AT_CAPTURE_FILE([file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
+ [[test-ovsdb log-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
[[file: open successful
file: write:[0] successful
file: write:[1] successful
@@ -141,7 +141,7 @@ file: write:[2] successful
]], [ignore])
AT_CHECK([echo 'xxx' >> file])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read read read read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read read read read], [0],
[[file: open successful
file: read: [0]
file: read: [1]
@@ -152,10 +152,10 @@ AT_CHECK([test -f .file.~lock~])
AT_CLEANUP
AT_SETUP([write, add corrupted data, read, overwrite])
-AT_KEYWORDS([ovsdb file])
+AT_KEYWORDS([ovsdb log])
AT_CAPTURE_FILE([file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
+ [[test-ovsdb log-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
[[file: open successful
file: write:[0] successful
file: write:[1] successful
@@ -163,7 +163,7 @@ file: write:[2] successful
]], [ignore])
AT_CHECK([echo 'xxx' >> file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_RDWR' read read read read 'write:[3]']], [0],
+ [[test-ovsdb log-io file 'O_RDWR' read read read read 'write:[3]']], [0],
[[file: open successful
file: read: [0]
file: read: [1]
@@ -172,22 +172,22 @@ file: read failed: syntax error: file: parse error at offset 174 in header line
file: write:[3] successful
]], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read read read read read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read read read read read], [0],
[[file: open successful
file: read: [0]
file: read: [1]
file: read: [2]
file: read: [3]
-file: read: end of file
+file: read: end of log
]], [ignore])
AT_CHECK([test -f .file.~lock~])
AT_CLEANUP
AT_SETUP([write, corrupt some data, read, overwrite])
-AT_KEYWORDS([ovsdb file])
+AT_KEYWORDS([ovsdb log])
AT_CAPTURE_FILE([file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
+ [[test-ovsdb log-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
[[file: open successful
file: write:[0] successful
file: write:[1] successful
@@ -198,7 +198,7 @@ AT_CHECK([mv file.tmp file])
AT_CHECK([[grep -c '\[3]' file]], [0], [1
])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_RDWR' read read read 'write:["longer data"]']], [0],
+ [[test-ovsdb log-io file 'O_RDWR' read read read 'write:["longer data"]']], [0],
[[file: open successful
file: read: [0]
file: read: [1]
@@ -206,21 +206,21 @@ file: read failed: syntax error: file: 4 bytes starting at offset 170 have SHA-1
file: write:["longer data"] successful
]], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read read read read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read read read read], [0],
[[file: open successful
file: read: [0]
file: read: [1]
file: read: ["longer data"]
-file: read: end of file
+file: read: end of log
]], [ignore])
AT_CHECK([test -f .file.~lock~])
AT_CLEANUP
AT_SETUP([write, truncate file, read, overwrite])
-AT_KEYWORDS([ovsdb file])
+AT_KEYWORDS([ovsdb log])
AT_CAPTURE_FILE([file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
+ [[test-ovsdb log-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
[[file: open successful
file: write:[0] successful
file: write:[1] successful
@@ -231,7 +231,7 @@ AT_CHECK([mv file.tmp file])
AT_CHECK([[grep -c '^2$' file]], [0], [1
])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_RDWR' read read read 'write:["longer data"]']], [0],
+ [[test-ovsdb log-io file 'O_RDWR' read read read 'write:["longer data"]']], [0],
[[file: open successful
file: read: [0]
file: read: [1]
@@ -239,21 +239,21 @@ file: read failed: I/O error: file: error reading 4 bytes starting at offset 170
file: write:["longer data"] successful
]], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read read read read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read read read read], [0],
[[file: open successful
file: read: [0]
file: read: [1]
file: read: ["longer data"]
-file: read: end of file
+file: read: end of log
]], [ignore])
AT_CHECK([test -f .file.~lock~])
AT_CLEANUP
AT_SETUP([write bad JSON, read, overwrite])
-AT_KEYWORDS([ovsdb file])
+AT_KEYWORDS([ovsdb log])
AT_CAPTURE_FILE([file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
+ [[test-ovsdb log-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
[[file: open successful
file: write:[0] successful
file: write:[1] successful
@@ -261,7 +261,7 @@ file: write:[2] successful
]], [ignore])
AT_CHECK([[printf '%s\n%s\n' 'OVSDB JSON 5 d910b02871075d3156ec8675dfc95b7d5d640aa6' 'null' >> file]])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_RDWR' read read read read 'write:["replacement data"]']], [0],
+ [[test-ovsdb log-io file 'O_RDWR' read read read read 'write:["replacement data"]']], [0],
[[file: open successful
file: read: [0]
file: read: [1]
@@ -270,13 +270,13 @@ file: read failed: syntax error: file: 5 bytes starting at offset 228 are not va
file: write:["replacement data"] successful
]], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read read read read read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read read read read read], [0],
[[file: open successful
file: read: [0]
file: read: [1]
file: read: [2]
file: read: ["replacement data"]
-file: read: end of file
+file: read: end of log
]], [ignore])
AT_CHECK([test -f .file.~lock~])
AT_CLEANUP
diff --git a/tests/ovsdb.at b/tests/ovsdb.at
index 0e0e63b08..d3d53bcc7 100644
--- a/tests/ovsdb.at
+++ b/tests/ovsdb.at
@@ -22,7 +22,7 @@ m4_define([OVSDB_CHECK_NEGATIVE],
[0], [ignore], [ignore])
AT_CLEANUP])
-m4_include([tests/ovsdb-file.at])
+m4_include([tests/ovsdb-log.at])
m4_include([tests/ovsdb-types.at])
m4_include([tests/ovsdb-data.at])
m4_include([tests/ovsdb-column.at])
diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c
index bee1818bc..72fada146 100644
--- a/tests/test-ovsdb.c
+++ b/tests/test-ovsdb.c
@@ -30,7 +30,7 @@
#include "ovsdb-types.h"
#include "ovsdb/column.h"
#include "ovsdb/condition.h"
-#include "ovsdb/file.h"
+#include "ovsdb/log.h"
#include "ovsdb/ovsdb.h"
#include "ovsdb/query.h"
#include "ovsdb/row.h"
@@ -98,7 +98,7 @@ usage(void)
{
printf("%s: Open vSwitch database test utility\n"
"usage: %s [OPTIONS] COMMAND [ARG...]\n\n"
- " file-io FILE FLAGS COMMAND...\n"
+ " log-io FILE FLAGS COMMAND...\n"
" open FILE with FLAGS, run COMMANDs\n"
" parse-atomic-type TYPE\n"
" parse TYPE as OVSDB atomic type, and re-serialize\n"
@@ -196,13 +196,13 @@ check_ovsdb_error(struct ovsdb_error *error)
/* Command implementations. */
static void
-do_file_io(int argc, char *argv[])
+do_log_io(int argc, char *argv[])
{
const char *name = argv[1];
char *mode = argv[2];
struct ovsdb_error *error;
- struct ovsdb_file *file;
+ struct ovsdb_log *log;
char *save_ptr = NULL;
const char *token;
int flags;
@@ -226,7 +226,7 @@ do_file_io(int argc, char *argv[])
}
}
- check_ovsdb_error(ovsdb_file_open(name, flags, &file));
+ check_ovsdb_error(ovsdb_log_open(name, flags, &log));
printf("%s: open successful\n", name);
for (i = 3; i < argc; i++) {
@@ -234,24 +234,24 @@ do_file_io(int argc, char *argv[])
if (!strcmp(command, "read")) {
struct json *json;
- error = ovsdb_file_read(file, &json);
+ error = ovsdb_log_read(log, &json);
if (!error) {
printf("%s: read: ", name);
if (json) {
print_and_free_json(json);
} else {
- printf("end of file\n");
+ printf("end of log\n");
}
continue;
}
} else if (!strncmp(command, "write:", 6)) {
struct json *json = parse_json(command + 6);
- error = ovsdb_file_write(file, json);
+ error = ovsdb_log_write(log, json);
json_destroy(json);
} else if (!strcmp(command, "commit")) {
- error = ovsdb_file_commit(file);
+ error = ovsdb_log_commit(log);
} else {
- ovs_fatal(0, "unknown file-io command \"%s\"", command);
+ ovs_fatal(0, "unknown log-io command \"%s\"", command);
}
if (error) {
char *s = ovsdb_error_to_string(error);
@@ -262,7 +262,7 @@ do_file_io(int argc, char *argv[])
}
}
- ovsdb_file_close(file);
+ ovsdb_log_close(log);
}
static void
@@ -1207,7 +1207,7 @@ do_transact(int argc, char *argv[])
}
static struct command all_commands[] = {
- { "file-io", 2, INT_MAX, do_file_io },
+ { "log-io", 2, INT_MAX, do_log_io },
{ "parse-atomic-type", 1, 1, do_parse_atomic_type },
{ "parse-type", 1, 1, do_parse_type },
{ "parse-atoms", 2, INT_MAX, do_parse_atoms },