Fix test program to work with /etc/hosts and display all files recursively.
authorRichard W.M. Jones <rjones@redhat.com>
Wed, 7 May 2008 07:42:41 +0000 (08:42 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Wed, 7 May 2008 07:42:41 +0000 (08:42 +0100)
Makefile.in
test_augeas.ml

index 178269e..97f7e15 100644 (file)
@@ -55,7 +55,8 @@ test_augeas: test_augeas.cmo test_root
 test_root:
        rm -rf $@
        mkdir $@
-       cp /etc/hosts $@/
+       mkdir $@/etc
+       cp /etc/hosts $@/etc/
 
 # Clean.
 
index 0124b58..1be88b7 100644 (file)
 
 let () =
   let aug =
-    let loadpath = Some "/usr/share/augeas/lenses" in
+    let loadpath = None in
     let flags = [ Augeas.AugSaveBackup ] in
     Augeas.create "test_root" loadpath flags in
 
-  (* Print all files. *)
-  let files = Augeas.matches aug "/files/*" in
-  List.iter print_endline files;
-
-  (* Print all Augeas-metainfo. *)
-  let augs = Augeas.matches aug "/augeas/*" in
-  List.iter print_endline augs;
-
+  (* Print all files recursively. *)
+  let rec print path =
+    if path <> "" then print_endline path;
+    let files = List.sort compare (Augeas.matches aug (path ^ "/*")) in
+    List.iter print files
+  in
+  print "";
 
   (* Run the garbage collector to check for internal errors. *)
   Gc.compact ()