Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / bsd / libarchive / dist / cpio / test / test_owner_parse.c
blob1adbce4a9fc310f197d35e0406c0ddfb98697f34
1 /*-
2 * Copyright (c) 2003-2007 Tim Kientzle
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 #include "test.h"
26 __FBSDID("$FreeBSD$");
28 #include "../cpio.h"
30 DEFINE_TEST(test_owner_parse)
32 int uid, gid;
34 cpio_progname = "Ignore this message";
36 assertEqualInt(0, owner_parse("root", &uid, &gid));
37 assertEqualInt(0, uid);
38 assertEqualInt(-1, gid);
41 assertEqualInt(0, owner_parse("root:", &uid, &gid));
42 assertEqualInt(0, uid);
43 assertEqualInt(0, gid);
45 assertEqualInt(0, owner_parse("root.", &uid, &gid));
46 assertEqualInt(0, uid);
47 assertEqualInt(0, gid);
50 * TODO: Lookup current user/group name, build strings and
51 * use those to verify username/groupname lookups for ordinary
52 * users.
56 * TODO: Rework owner_parse to either return a char * pointing
57 * to an error message or accept a function pointer to an
58 * error-reporting routine so that the following tests don't
59 * generate any output.
61 * Alternatively, redirect stderr temporarily to suppress the output.
64 assertEqualInt(1, owner_parse(":nonexistentgroup", &uid, &gid));
65 assertEqualInt(1, owner_parse("root:nonexistentgroup", &uid, &gid));
66 assertEqualInt(1,
67 owner_parse("nonexistentuser:nonexistentgroup", &uid, &gid));