2 // Automated Testing Framework (atf)
4 // Copyright (c) 2007 The NetBSD Foundation, Inc.
5 // All rights reserved.
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
10 // 1. Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 // 2. Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
16 // THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17 // CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 // IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 // GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 // IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 // IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "atf-c/utils.h"
40 atf::utils::cat_file(const std::string
& path
, const std::string
& prefix
)
42 atf_utils_cat_file(path
.c_str(), prefix
.c_str());
46 atf::utils::copy_file(const std::string
& source
, const std::string
& destination
)
48 atf_utils_copy_file(source
.c_str(), destination
.c_str());
52 atf::utils::compare_file(const std::string
& path
, const std::string
& contents
)
54 return atf_utils_compare_file(path
.c_str(), contents
.c_str());
58 atf::utils::create_file(const std::string
& path
, const std::string
& contents
)
60 atf_utils_create_file(path
.c_str(), "%s", contents
.c_str());
64 atf::utils::file_exists(const std::string
& path
)
66 return atf_utils_file_exists(path
.c_str());
70 atf::utils::fork(void)
74 return atf_utils_fork();
78 atf::utils::grep_file(const std::string
& regex
, const std::string
& path
)
80 return atf_utils_grep_file("%s", path
.c_str(), regex
.c_str());
84 atf::utils::grep_string(const std::string
& regex
, const std::string
& str
)
86 return atf_utils_grep_string("%s", str
.c_str(), regex
.c_str());
90 atf::utils::redirect(const int fd
, const std::string
& path
)
92 if (fd
== STDOUT_FILENO
)
94 else if (fd
== STDERR_FILENO
)
96 atf_utils_redirect(fd
, path
.c_str());
100 atf::utils::wait(const pid_t pid
, const int exitstatus
,
101 const std::string
& expout
, const std::string
& experr
)
103 atf_utils_wait(pid
, exitstatus
, expout
.c_str(), experr
.c_str());