Add facility to specify razor command when running tests.
This makes it easy to run under eg., valgrind as:
./details "libtool --mode=execute valgrind --leak-check=yes ../src/razor"
2 * Copyright (C) 2011-2012 J. Ali Harlow <ali@juiblex.co.uk>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
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.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include <sys/types.h>
33 #include "razor-internal.h"
39 static int allow_all_root_names = 0;
42 * Primarily intended for testing named roots under UNIX platforms.
45 razor_disable_root_name_checks(int disable)
47 allow_all_root_names = disable;
51 razor_allow_all_root_names(void)
53 return allow_all_root_names;
56 RAZOR_EXPORT struct razor_error *
57 razor_atomic_get_error(struct razor_atomic *atomic)
62 RAZOR_EXPORT const char *
63 razor_atomic_get_error_msg(struct razor_atomic *atomic)
66 return razor_error_get_msg(atomic->error);
72 razor_atomic_abort(struct razor_atomic *atomic, int domain, int code,
73 const char *error_msg)
76 atomic->error = razor_error_new_str(domain, code, NULL,
81 razor_atomic_propagate_error(struct razor_atomic *atomic,
82 struct razor_error *error, const char *summary)
85 atomic->error = razor_error_dup(error, summary);
89 razor_atomic_in_error_state(struct razor_atomic *atomic)
91 return atomic->error && !atomic->in_undo;
97 * Common code with atomic-none and atomic-emulate
100 #define RAZOR_ASCII_ISALPHA(c) \
101 ((c) >= 'A' && (c) <= 'Z' || (c) >= 'a' && (c) <= 'z')
104 razor_valid_root_name(const char *name)
106 if (razor_allow_all_root_names()) {
108 return !strpbrk(name, "/\\");
110 return !strchr(name, '/');
115 return RAZOR_ASCII_ISALPHA(name[0]) && name[1] == ':' &&
118 return name[0] == '\0';
123 razor_atomic_write(struct razor_atomic *atomic, int fd, const void *data,
128 if (razor_atomic_in_error_state(atomic))
132 written = write(fd, data, size);
134 atomic->error = razor_error_new_posix(NULL);
149 razor_atomic_sync(struct razor_atomic *atomic, int handle)
151 if (razor_atomic_in_error_state(atomic))
154 if (fsync(handle) < 0) {
155 atomic->error = razor_error_new_posix(NULL);
163 razor_atomic_close(struct razor_atomic *atomic, int fd)
165 if (razor_atomic_in_error_state(atomic))
169 atomic->error = razor_error_new_posix(NULL);
176 #endif /* !HAVE_WINDOWS_KTM */