summaryrefslogtreecommitdiffstats
path: root/ini/ini_fileobj.c
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2012-05-11 09:31:24 -0400
committerJakub Hrozek <jhrozek@redhat.com>2012-10-17 14:02:51 +0200
commit46e4b24e313cf0885cc2dd8ab090a0e1227a98fc (patch)
tree6949edbad313f66a6a35d78922ac46bd7e08c22f /ini/ini_fileobj.c
parent7ad6e8180022b0f373fa253d00f9bed29d27cbde (diff)
downloadding-libs-46e4b24e313cf0885cc2dd8ab090a0e1227a98fc.tar.gz
ding-libs-46e4b24e313cf0885cc2dd8ab090a0e1227a98fc.tar.xz
ding-libs-46e4b24e313cf0885cc2dd8ab090a0e1227a98fc.zip
Fix permission checking unit test
The unit test was broken. The wrong function was used. To make sure everything is correct I also added a convenience function to print the internals if the file context object. The unit test is fixed to use relative paths consitently. Also added nice statements at the beggining and the end of the unit test functions where they were missing.
Diffstat (limited to 'ini/ini_fileobj.c')
-rw-r--r--ini/ini_fileobj.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/ini/ini_fileobj.c b/ini/ini_fileobj.c
index 3f348a7..73d7c4c 100644
--- a/ini/ini_fileobj.c
+++ b/ini/ini_fileobj.c
@@ -485,7 +485,7 @@ int ini_config_access_check(struct ini_cfgfile *file_ctx,
}
-/* Determins if two file contexts are different by comparing:
+/* Determines if two file contexts are different by comparing:
* - time stamp
* - device ID
* - i-node
@@ -505,6 +505,13 @@ int ini_config_changed(struct ini_cfgfile *file_ctx1,
*changed = 0;
+ /* Unfortunately the time is not granular enough
+ * to detect the change if run during the unit test.
+ * In future when a more granular version of stat
+ * is available we should switch to it and update
+ * the unit test.
+ */
+
if((file_ctx1->file_stats.st_mtime !=
file_ctx2->file_stats.st_mtime) ||
(file_ctx1->file_stats.st_dev !=
@@ -518,3 +525,35 @@ int ini_config_changed(struct ini_cfgfile *file_ctx1,
TRACE_FLOW_EXIT();
return EOK;
}
+
+/* Print the file object contents */
+void ini_config_file_print(struct ini_cfgfile *file_ctx)
+{
+ TRACE_FLOW_ENTRY();
+ if (file_ctx == NULL) {
+ printf("No file object\n.");
+ }
+ else {
+ printf("File name: %s\n", (file_ctx->filename) ? file_ctx->filename : "NULL");
+ printf("File is %s\n", (file_ctx->file) ? "open" : "closed");
+ printf("Error level is %d\n", file_ctx->error_level);
+ printf("Collision flags %u\n", file_ctx->collision_flags);
+ printf("Metadata flags %u\n", file_ctx->metadata_flags);
+ if (file_ctx->error_list) col_print_collection(file_ctx->error_list);
+ else printf("Error list is empty.");
+ printf("Stats flag st_dev %li\n", file_ctx->file_stats.st_dev);
+ printf("Stats flag st_ino %li\n", file_ctx->file_stats.st_ino);
+ printf("Stats flag st_mode %u\n", file_ctx->file_stats.st_mode);
+ printf("Stats flag st_nlink %li\n", file_ctx->file_stats.st_nlink);
+ printf("Stats flag st_uid %u\n", file_ctx->file_stats.st_uid);
+ printf("Stats flag st_gid %u\n", file_ctx->file_stats.st_gid);
+ printf("Stats flag st_rdev %li\n", file_ctx->file_stats.st_rdev);
+ printf("Stats flag st_size %lu\n", file_ctx->file_stats.st_size);
+ printf("Stats flag st_blocks %li\n", file_ctx->file_stats.st_blocks);
+ printf("Stats flag st_atime %ld\n", file_ctx->file_stats.st_atime);
+ printf("Stats flag st_mtime %ld\n", file_ctx->file_stats.st_mtime);
+ printf("Stats flag st_ctime %ld\n", file_ctx->file_stats.st_ctime);
+ printf("Count %u\n", file_ctx->count);
+ }
+ TRACE_FLOW_EXIT();
+}