[augeas-devel] [PATCH] /etc/ethers: new lens and test

David Lutterkort lutter at redhat.com
Mon Oct 5 18:19:06 UTC 2009


On Mon, 2009-10-05 at 10:51 +0900, Satoru SATOH wrote:
> The followings adds a new lens for /etc/ethers and associated test.

Very nice. I have two little comments before committing:

> Signed-off-by: Satoru SATOH <satoru.satoh at gmail.com>
>
> diff --git a/lenses/ethers.aug b/lenses/ethers.aug
> new file mode 100644
> index 0000000..dc6f1ac
> --- /dev/null
> +++ b/lenses/ethers.aug
> @@ -0,0 +1,26 @@
> +(* Parsing /etc/ethers *)
> +
> +module Ethers =
> +  autoload xfm
> +
> +  let sep_tab = Util.del_ws_tab
> +  let sep_spc = Util.del_ws_spc
> +
> +  let eol = del /[ \t]*\n/ "\n"
> +  let indent = del /[ \t]*/ ""
> +
> +  let comment = Util.comment
> +  let empty   = [ del /[ \t]*#?[ \t]*\n/ "\n" ]
> +
> +  let word = /[^# \n\t]+/
> +  let address =
> +    let chr = /[0-9a-fA-F][0-9a-fA-F]/ in
> +      chr . ":" . chr . ":" . chr . ":" . chr . ":" . chr . ":" . chr

chr should match a single hexadecimal character, i.e. it should
be /[0-9a-fA-F][0-9a-fA-F]?/

> +  let record = [ seq "ether" . indent .
> +                              [ label "ethaddr" . store  address ] . sep_tab .
> +                              [ label "ip" . store word ] . eol ]

How about renaming 'ethaddr' to 'mac' ?

> diff --git a/lenses/tests/test_ethers.aug b/lenses/tests/test_ethers.aug
> new file mode 100644
> index 0000000..ca1ed39
> --- /dev/null
> +++ b/lenses/tests/test_ethers.aug
> @@ -0,0 +1,61 @@
> +(* Tests for the Ethers module *)
> +

I really like this test - very thorough.

David





More information about the augeas-devel mailing list