1*49cdfc7eSAndroid Build Coastguard Worker /*
2*49cdfc7eSAndroid Build Coastguard Worker * Copyright (C) 2014 Linux Test Project, Inc.
3*49cdfc7eSAndroid Build Coastguard Worker *
4*49cdfc7eSAndroid Build Coastguard Worker * This program is free software; you can redistribute it and/or modify it
5*49cdfc7eSAndroid Build Coastguard Worker * under the terms of version 2 of the GNU General Public License as
6*49cdfc7eSAndroid Build Coastguard Worker * published by the Free Software Foundation.
7*49cdfc7eSAndroid Build Coastguard Worker *
8*49cdfc7eSAndroid Build Coastguard Worker * This program is distributed in the hope that it would be useful, but
9*49cdfc7eSAndroid Build Coastguard Worker * WITHOUT ANY WARRANTY; without even the implied warranty of
10*49cdfc7eSAndroid Build Coastguard Worker * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11*49cdfc7eSAndroid Build Coastguard Worker *
12*49cdfc7eSAndroid Build Coastguard Worker * Further, this software is distributed without any warranty that it is
13*49cdfc7eSAndroid Build Coastguard Worker * free of the rightful claim of any third person regarding infringement
14*49cdfc7eSAndroid Build Coastguard Worker * or the like. Any license provided herein, whether implied or
15*49cdfc7eSAndroid Build Coastguard Worker * otherwise, applies only to this software file. Patent licenses, if
16*49cdfc7eSAndroid Build Coastguard Worker * any, provided herein do not apply to combinations of this program with
17*49cdfc7eSAndroid Build Coastguard Worker * other software, or any other product whatsoever.
18*49cdfc7eSAndroid Build Coastguard Worker */
19*49cdfc7eSAndroid Build Coastguard Worker
20*49cdfc7eSAndroid Build Coastguard Worker #include <errno.h>
21*49cdfc7eSAndroid Build Coastguard Worker #include <fcntl.h>
22*49cdfc7eSAndroid Build Coastguard Worker #include <string.h>
23*49cdfc7eSAndroid Build Coastguard Worker #include "test.h"
24*49cdfc7eSAndroid Build Coastguard Worker #include "safe_macros.h"
25*49cdfc7eSAndroid Build Coastguard Worker
26*49cdfc7eSAndroid Build Coastguard Worker #define OUTPUT_FNAME "output"
27*49cdfc7eSAndroid Build Coastguard Worker #define LTPROOT "/opt/ltp"
28*49cdfc7eSAndroid Build Coastguard Worker
29*49cdfc7eSAndroid Build Coastguard Worker char *TCID = "dataroot";
30*49cdfc7eSAndroid Build Coastguard Worker int TST_TOTAL = 1;
31*49cdfc7eSAndroid Build Coastguard Worker
cmp_paths(const char * p1,const char * p2,const char * s)32*49cdfc7eSAndroid Build Coastguard Worker static void cmp_paths(const char *p1, const char *p2, const char *s)
33*49cdfc7eSAndroid Build Coastguard Worker {
34*49cdfc7eSAndroid Build Coastguard Worker if (strncmp(p1, p2, PATH_MAX) == 0)
35*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TPASS, "%s", s);
36*49cdfc7eSAndroid Build Coastguard Worker else
37*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TFAIL, "%s, %s != %s", s, p1, p2);
38*49cdfc7eSAndroid Build Coastguard Worker }
39*49cdfc7eSAndroid Build Coastguard Worker
main(void)40*49cdfc7eSAndroid Build Coastguard Worker int main(void)
41*49cdfc7eSAndroid Build Coastguard Worker {
42*49cdfc7eSAndroid Build Coastguard Worker const char *dataroot;
43*49cdfc7eSAndroid Build Coastguard Worker char curdir[PATH_MAX], tmp[PATH_MAX];
44*49cdfc7eSAndroid Build Coastguard Worker
45*49cdfc7eSAndroid Build Coastguard Worker if (getcwd(curdir, PATH_MAX) == NULL)
46*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TBROK, NULL, "getcwd");
47*49cdfc7eSAndroid Build Coastguard Worker
48*49cdfc7eSAndroid Build Coastguard Worker /* no LTPROOT, tmpdir */
49*49cdfc7eSAndroid Build Coastguard Worker tst_tmpdir();
50*49cdfc7eSAndroid Build Coastguard Worker dataroot = tst_dataroot();
51*49cdfc7eSAndroid Build Coastguard Worker snprintf(tmp, PATH_MAX, "%s/datafiles", curdir);
52*49cdfc7eSAndroid Build Coastguard Worker cmp_paths(dataroot, tmp, "no LTPROOT, tmpdir, "
53*49cdfc7eSAndroid Build Coastguard Worker "dataroot == $STARTWD/datafiles");
54*49cdfc7eSAndroid Build Coastguard Worker tst_rmdir();
55*49cdfc7eSAndroid Build Coastguard Worker
56*49cdfc7eSAndroid Build Coastguard Worker tst_exit();
57*49cdfc7eSAndroid Build Coastguard Worker }
58*49cdfc7eSAndroid Build Coastguard Worker
59