[prev in list] [next in list] [prev in thread] [next in thread]
List: util-linux-ng
Subject: Re: [PATCH 3/8] libuuid: add uuid_generate_file() function
From: Karel Zak <kzak () redhat ! com>
Date: 2015-10-16 9:18:55
Message-ID: 20151016091855.GA2990 () ws ! net ! home
[Download RAW message or body]
On Tue, Oct 13, 2015 at 12:29:09PM +0100, Sami Kerola wrote:
> The uuid_generate_file() allows generating UUID using input file, and thus
> leading to stable output. Purpose of this function is to have a facility
> that allows tests to be wrote.
Well, if you want to generate non-random stuff then it seems enough
to modify __uuid_generate_random() and __uuid_generate_time()
to return non-random stuff on -DLIBUUID_ENABLE_TEST.
The problem is that things like get_clock(), pack, unpack, parse and
unparse functions will be still untested.
What about to support random UUIDs in our tests and modify
the __uuid_generate functions to copy unpacked raw result to any
file? Something like:
int __uuid_generate_time(uuid_t out, int *num)
{
... generate struct uu as usually ...
#ifdef LIBUUID_ENABLE_TEST
ts_path = genenv("LIBUUID_TEST_PATH");
if (ts_path)
write_raw_uuid(uu, ts_path);
#endif
return ret;
}
where write_uraw_uuid() is function to write struct uuid to the
<ts_path>/<pid>.
Then we can write
test_uuid --random|--time <file>
this program
1/ ask libuuid for a new UUID
2/ unparse and unpack to get struct uuid
3/ write struct uuid to the <file> by write_uraw_uuid()
and in the shell script we can by diff -u compare $LIBUUID_TEST_PATH/<pid>
with <file>.
The <pid> is also possible to use to check if UUID has been really
generated by uuidd. (It would be nice to have two sub-tests, one with
uuidd and one without uuid.)
Note that uuid_unpack() is not exported by library API, so you have to
link libuuid/src/unpack.c directly to the test_uuid.c.
(It would be also possible to analyze struct uuid from
$LIBUUID_TEST_PATH to make sure that for example get_node_id() works
as expected, etc... but this is not urgent.)
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic