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