author | Peter D. Barnes, Jr. <barnes26@llnl.gov> |
Tue, 09 Dec 2014 13:17:49 -0800 | |
changeset 11097 | caafe12b0378 |
parent 11046 | e62bccfbe56e |
child 11131 | 6a448ac28669 |
permissions | -rw-r--r-- |
7515 | 1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2008 INRIA |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License version 2 as |
|
7 |
* published by the Free Software Foundation; |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 |
* |
|
18 |
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
|
19 |
*/ |
|
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
20 |
#include "system-path.h" |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
21 |
#include "fatal-error.h" |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
22 |
#include "assert.h" |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
23 |
#include "log.h" |
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
24 |
#include "ns3/core-config.h" |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7756
diff
changeset
|
25 |
#include <cstdlib> |
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7756
diff
changeset
|
26 |
#include <cerrno> |
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7756
diff
changeset
|
27 |
#include <cstring> |
11097
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
28 |
|
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
29 |
|
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
30 |
#if defined (HAVE_DIRENT_H) and defined (HAVE_SYS_TYPES_H) |
11097
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
31 |
/** Do we have an \c opendir function? */ |
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
32 |
#define HAVE_OPENDIR |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
33 |
#include <sys/types.h> |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
34 |
#include <dirent.h> |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
35 |
#endif |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
36 |
#if defined (HAVE_SYS_STAT_H) and defined (HAVE_SYS_TYPES_H) |
11097
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
37 |
/** Do we have a \c makedir function? */ |
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
38 |
#define HAVE_MKDIR_H |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
39 |
#include <sys/types.h> |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
40 |
#include <sys/stat.h> |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
41 |
#endif |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
42 |
#include <sstream> |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
43 |
#ifdef __APPLE__ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
44 |
#include <mach-o/dyld.h> |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
45 |
#endif /* __APPLE__ */ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
46 |
|
7485
9bec9af5e3c8
make ns-3 compile on FreeBSD-8.2
Colin Perkins <csp@csperkins.org>
parents:
7379
diff
changeset
|
47 |
#ifdef __FreeBSD__ |
9bec9af5e3c8
make ns-3 compile on FreeBSD-8.2
Colin Perkins <csp@csperkins.org>
parents:
7379
diff
changeset
|
48 |
#include <sys/types.h> |
9bec9af5e3c8
make ns-3 compile on FreeBSD-8.2
Colin Perkins <csp@csperkins.org>
parents:
7379
diff
changeset
|
49 |
#include <sys/sysctl.h> |
9bec9af5e3c8
make ns-3 compile on FreeBSD-8.2
Colin Perkins <csp@csperkins.org>
parents:
7379
diff
changeset
|
50 |
#endif |
9bec9af5e3c8
make ns-3 compile on FreeBSD-8.2
Colin Perkins <csp@csperkins.org>
parents:
7379
diff
changeset
|
51 |
|
7756
a3a5f9215aae
Explicitly including the unistd.h header file is needed on some systems where POSIX system calls are used
Tom Goff <tgoff@tgoff.net>
parents:
7515
diff
changeset
|
52 |
#ifdef __linux__ |
a3a5f9215aae
Explicitly including the unistd.h header file is needed on some systems where POSIX system calls are used
Tom Goff <tgoff@tgoff.net>
parents:
7515
diff
changeset
|
53 |
#include <unistd.h> |
a3a5f9215aae
Explicitly including the unistd.h header file is needed on some systems where POSIX system calls are used
Tom Goff <tgoff@tgoff.net>
parents:
7515
diff
changeset
|
54 |
#endif |
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
55 |
|
11097
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
56 |
/** |
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
57 |
* \def SYSTEM_PATH_SEP |
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
58 |
* System-specific path separator used between directory names. |
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
59 |
*/ |
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
60 |
#if defined (__win32__) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
61 |
#define SYSTEM_PATH_SEP "\\" |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
62 |
#else |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
63 |
#define SYSTEM_PATH_SEP "/" |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
64 |
#endif |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
65 |
|
11097
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
66 |
/** |
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
67 |
* \file |
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
68 |
* \ingroup systempath |
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
69 |
* System-independent file and directory function definitions. |
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
70 |
*/ |
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
71 |
|
10968
2d29fee2b7b8
[Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9894
diff
changeset
|
72 |
namespace ns3 { |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
73 |
|
10968
2d29fee2b7b8
[Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9894
diff
changeset
|
74 |
NS_LOG_COMPONENT_DEFINE ("SystemPath"); |
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
75 |
|
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
76 |
namespace SystemPath { |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
77 |
|
11046
e62bccfbe56e
[Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
78 |
/** |
e62bccfbe56e
[Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
79 |
* \ingroup systempath |
e62bccfbe56e
[Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
80 |
* \brief Get the directory path for a file. |
e62bccfbe56e
[Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
81 |
* |
e62bccfbe56e
[Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
82 |
* This is an internal function (by virtue of not being |
e62bccfbe56e
[Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
83 |
* declared in a \c .h file); the public API is FindSelfDirectory(). |
e62bccfbe56e
[Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
84 |
* |
e62bccfbe56e
[Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
85 |
* \param path The full path to a file. |
e62bccfbe56e
[Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
86 |
* \returns The full path to the containing directory. |
e62bccfbe56e
[Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
87 |
*/ |
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
88 |
std::string Dirname (std::string path) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
89 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
90 |
NS_LOG_FUNCTION (path); |
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
91 |
std::list<std::string> elements = Split (path); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
92 |
std::list<std::string>::const_iterator last = elements.end(); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
93 |
last--; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
94 |
return Join (elements.begin (), last); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
95 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
96 |
|
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
97 |
std::string FindSelfDirectory (void) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
98 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
99 |
/** |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
100 |
* This function returns the path to the running $PREFIX. |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
101 |
* Mac OS X: _NSGetExecutablePath() (man 3 dyld) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
102 |
* Linux: readlink /proc/self/exe |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
103 |
* Solaris: getexecname() |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
104 |
* FreeBSD: sysctl CTL_KERN KERN_PROC KERN_PROC_PATHNAME -1 |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
105 |
* BSD with procfs: readlink /proc/curproc/file |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
106 |
* Windows: GetModuleFileName() with hModule = NULL |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
107 |
*/ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
108 |
NS_LOG_FUNCTION_NOARGS (); |
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
109 |
std::string filename; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
110 |
#if defined(__linux__) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
111 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
112 |
ssize_t size = 1024; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
113 |
char *buffer = (char*)malloc (size); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
114 |
memset (buffer, 0, size); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
115 |
int status; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
116 |
while (true) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
117 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
118 |
status = readlink("/proc/self/exe", buffer, size); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
119 |
if (status != 1 || (status == -1 && errno != ENAMETOOLONG)) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
120 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
121 |
break; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
122 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
123 |
size *= 2; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
124 |
free (buffer); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
125 |
buffer = (char*)malloc (size); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
126 |
memset (buffer, 0, size); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
127 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
128 |
if (status == -1) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
129 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
130 |
NS_FATAL_ERROR ("Oops, could not find self directory."); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
131 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
132 |
filename = buffer; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
133 |
free (buffer); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
134 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
135 |
#elif defined (__win32__) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
136 |
{ |
9894
ac4e52a91d5d
Doxygenate todo's
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9785
diff
changeset
|
137 |
/// \todo untested. it should work if code is compiled with |
ac4e52a91d5d
Doxygenate todo's
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9785
diff
changeset
|
138 |
/// LPTSTR = char * |
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
139 |
DWORD size = 1024; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
140 |
LPTSTR lpFilename = (LPTSTR) malloc (sizeof(TCHAR) * size); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
141 |
DWORD status = GetModuleFilename (0, lpFilename, size); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
142 |
while (status == size) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
143 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
144 |
size = size * 2; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
145 |
free (lpFilename); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
146 |
lpFilename = (LPTSTR) malloc (sizeof(TCHAR) * size); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
147 |
status = GetModuleFilename (0, lpFilename, size); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
148 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
149 |
NS_ASSERT (status != 0); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
150 |
filename = lpFilename; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
151 |
free (lpFilename); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
152 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
153 |
#elif defined (__APPLE__) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
154 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
155 |
uint32_t bufsize = 1024; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
156 |
char *buffer = (char *) malloc (bufsize); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
157 |
NS_ASSERT (buffer != 0); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
158 |
int status = _NSGetExecutablePath (buffer, &bufsize); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
159 |
if (status == -1) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
160 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
161 |
free (buffer); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
162 |
buffer = (char *) malloc (bufsize); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
163 |
status = _NSGetExecutablePath (buffer, &bufsize); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
164 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
165 |
NS_ASSERT (status == 0); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
166 |
filename = buffer; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
167 |
free (buffer); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
168 |
} |
7485
9bec9af5e3c8
make ns-3 compile on FreeBSD-8.2
Colin Perkins <csp@csperkins.org>
parents:
7379
diff
changeset
|
169 |
#elif defined (__FreeBSD__) |
9bec9af5e3c8
make ns-3 compile on FreeBSD-8.2
Colin Perkins <csp@csperkins.org>
parents:
7379
diff
changeset
|
170 |
{ |
9bec9af5e3c8
make ns-3 compile on FreeBSD-8.2
Colin Perkins <csp@csperkins.org>
parents:
7379
diff
changeset
|
171 |
int mib[4]; |
9bec9af5e3c8
make ns-3 compile on FreeBSD-8.2
Colin Perkins <csp@csperkins.org>
parents:
7379
diff
changeset
|
172 |
size_t bufSize = 1024; |
9bec9af5e3c8
make ns-3 compile on FreeBSD-8.2
Colin Perkins <csp@csperkins.org>
parents:
7379
diff
changeset
|
173 |
char *buf = (char *) malloc(bufSize); |
9bec9af5e3c8
make ns-3 compile on FreeBSD-8.2
Colin Perkins <csp@csperkins.org>
parents:
7379
diff
changeset
|
174 |
|
9bec9af5e3c8
make ns-3 compile on FreeBSD-8.2
Colin Perkins <csp@csperkins.org>
parents:
7379
diff
changeset
|
175 |
mib[0] = CTL_KERN; |
9bec9af5e3c8
make ns-3 compile on FreeBSD-8.2
Colin Perkins <csp@csperkins.org>
parents:
7379
diff
changeset
|
176 |
mib[1] = KERN_PROC; |
9bec9af5e3c8
make ns-3 compile on FreeBSD-8.2
Colin Perkins <csp@csperkins.org>
parents:
7379
diff
changeset
|
177 |
mib[2] = KERN_PROC_PATHNAME; |
9bec9af5e3c8
make ns-3 compile on FreeBSD-8.2
Colin Perkins <csp@csperkins.org>
parents:
7379
diff
changeset
|
178 |
mib[3] = -1; |
9bec9af5e3c8
make ns-3 compile on FreeBSD-8.2
Colin Perkins <csp@csperkins.org>
parents:
7379
diff
changeset
|
179 |
|
9bec9af5e3c8
make ns-3 compile on FreeBSD-8.2
Colin Perkins <csp@csperkins.org>
parents:
7379
diff
changeset
|
180 |
sysctl(mib, 4, buf, &bufSize, NULL, 0); |
9bec9af5e3c8
make ns-3 compile on FreeBSD-8.2
Colin Perkins <csp@csperkins.org>
parents:
7379
diff
changeset
|
181 |
filename = buf; |
9bec9af5e3c8
make ns-3 compile on FreeBSD-8.2
Colin Perkins <csp@csperkins.org>
parents:
7379
diff
changeset
|
182 |
} |
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
183 |
#endif |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
184 |
return Dirname (filename); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
185 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
186 |
|
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
187 |
std::string Append (std::string left, std::string right) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
188 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
189 |
// removing trailing separators from 'left' |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
190 |
NS_LOG_FUNCTION (left << right); |
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
191 |
while (true) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
192 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
193 |
std::string::size_type lastSep = left.rfind (SYSTEM_PATH_SEP); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
194 |
if (lastSep != left.size () - 1) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
195 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
196 |
break; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
197 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
198 |
left = left.substr (0, left.size () - 1); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
199 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
200 |
std::string retval = left + SYSTEM_PATH_SEP + right; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
201 |
return retval; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
202 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
203 |
|
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
204 |
std::list<std::string> Split (std::string path) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
205 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
206 |
NS_LOG_FUNCTION (path); |
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
207 |
std::list<std::string> retval; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
208 |
std::string::size_type current = 0, next = 0; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
209 |
next = path.find (SYSTEM_PATH_SEP, current); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
210 |
while (next != std::string::npos) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
211 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
212 |
std::string item = path.substr (current, next - current); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
213 |
retval.push_back (item); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
214 |
current = next + 1; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
215 |
next = path.find (SYSTEM_PATH_SEP, current); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
216 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
217 |
std::string item = path.substr (current, next - current); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
218 |
retval.push_back (item); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
219 |
return retval; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
220 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
221 |
|
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
222 |
std::string Join (std::list<std::string>::const_iterator begin, |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
223 |
std::list<std::string>::const_iterator end) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
224 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
225 |
NS_LOG_FUNCTION (&begin << &end); |
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
226 |
std::string retval = ""; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
227 |
for (std::list<std::string>::const_iterator i = begin; i != end; i++) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
228 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
229 |
if (i == begin) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
230 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
231 |
retval = *i; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
232 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
233 |
else |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
234 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
235 |
retval = retval + SYSTEM_PATH_SEP + *i; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
236 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
237 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
238 |
return retval; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
239 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
240 |
|
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
241 |
std::list<std::string> ReadFiles (std::string path) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
242 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
243 |
NS_LOG_FUNCTION (path); |
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
244 |
std::list<std::string> files; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
245 |
#if defined HAVE_OPENDIR |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
246 |
DIR *dp = opendir (path.c_str ()); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
247 |
if (dp == NULL) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
248 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
249 |
NS_FATAL_ERROR ("Could not open directory=" << path); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
250 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
251 |
struct dirent *de = readdir (dp); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
252 |
while (de != 0) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
253 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
254 |
files.push_back (de->d_name); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
255 |
de = readdir (dp); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
256 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
257 |
closedir (dp); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
258 |
#elif defined (HAVE_FIND_FIRST_FILE) |
9894
ac4e52a91d5d
Doxygenate todo's
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9785
diff
changeset
|
259 |
/// \todo untested |
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
260 |
HANDLE hFind; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
261 |
WIN32_FIND_DATA fileData; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
262 |
|
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
263 |
hFind = FindFirstFile (path.c_str (), &FindFileData); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
264 |
if (hFind == INVALID_HANDLE_VALUE) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
265 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
266 |
NS_FATAL_ERROR ("Could not open directory=" << path); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
267 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
268 |
do |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
269 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
270 |
files.push_back (fileData.cFileName); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
271 |
} while (FindNextFile (hFind, &fileData)); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
272 |
FindClose(hFind); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
273 |
#else |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
274 |
#error "No support for reading a directory on this platform" |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
275 |
#endif |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
276 |
return files; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
277 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
278 |
|
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
279 |
std::string |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
280 |
MakeTemporaryDirectoryName (void) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
281 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
282 |
NS_LOG_FUNCTION_NOARGS (); |
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
283 |
char *path = NULL; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
284 |
|
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
285 |
path = getenv ("TMP"); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
286 |
if (path == NULL) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
287 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
288 |
path = getenv ("TEMP"); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
289 |
if (path == NULL) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
290 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
291 |
path = const_cast<char *> ("/tmp"); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
292 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
293 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
294 |
|
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
295 |
// |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
296 |
// Just in case the user wants to go back and find the output, we give |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
297 |
// a hint as to which dir we created by including a time hint. |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
298 |
// |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
299 |
time_t now = time (NULL); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
300 |
struct tm *tm_now = localtime (&now); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
301 |
// |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
302 |
// But we also randomize the name in case there are multiple users doing |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
303 |
// this at the same time |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
304 |
// |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
305 |
srand (time (0)); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
306 |
long int n = rand (); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
307 |
|
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
308 |
// |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
309 |
// The final path to the directory is going to look something like |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
310 |
// |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
311 |
// /tmp/ns3-14.30.29.32767 |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
312 |
// |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
313 |
// The first segment comes from one of the temporary directory env |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
314 |
// variables or /tmp if not found. The directory name starts with an |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
315 |
// identifier telling folks who is making all of the temp directories |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
316 |
// and then the local time (in this case 14.30.29 -- which is 2:30 and |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
317 |
// 29 seconds PM). |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
318 |
// |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
319 |
std::ostringstream oss; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
320 |
oss << path << SYSTEM_PATH_SEP << "ns-3." << tm_now->tm_hour << "." |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
321 |
<< tm_now->tm_min << "." << tm_now->tm_sec << "." << n; |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
322 |
|
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
323 |
return oss.str (); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
324 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
325 |
|
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
326 |
void |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
327 |
MakeDirectories (std::string path) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
328 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
329 |
NS_LOG_FUNCTION (path); |
11097
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
330 |
|
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
331 |
// Make sure all directories on the path exist |
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
332 |
std::list<std::string> elements = Split (path); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
333 |
for (std::list<std::string>::const_iterator i = elements.begin (); i != elements.end (); ++i) |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
334 |
{ |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
335 |
std::string tmp = Join (elements.begin (), i); |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
336 |
#if defined(HAVE_MKDIR_H) |
9785
97052ab05772
[Coverity] Unchecked return value (CHECKED_RETURN)
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9134
diff
changeset
|
337 |
if (mkdir (tmp.c_str (), S_IRWXU)) |
97052ab05772
[Coverity] Unchecked return value (CHECKED_RETURN)
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9134
diff
changeset
|
338 |
{ |
97052ab05772
[Coverity] Unchecked return value (CHECKED_RETURN)
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9134
diff
changeset
|
339 |
NS_LOG_ERROR ("failed creating directory " << tmp); |
97052ab05772
[Coverity] Unchecked return value (CHECKED_RETURN)
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9134
diff
changeset
|
340 |
} |
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
341 |
#endif |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
342 |
} |
11097
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
343 |
|
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
344 |
// Make the final directory. Is this redundant with last iteration above? |
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
345 |
#if defined(HAVE_MKDIR_H) |
11097
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
346 |
if (mkdir (path.c_str (), S_IRWXU)) |
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
347 |
{ |
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
348 |
NS_LOG_ERROR ("failed creating directory " << path); |
caafe12b0378
[Doxygen] OS functions: filesystem, threading, wall clock.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11046
diff
changeset
|
349 |
} |
7379
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
350 |
#endif |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
351 |
|
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
352 |
} |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
353 |
|
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
354 |
} // namespace SystemPath |
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
355 |
|
ff0d074f885a
add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff
changeset
|
356 |
} // namespace ns3 |