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