Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/atf/dist Pull up revision b94e200f2a6ce3d471033...
details: https://anonhg.NetBSD.org/src/rev/49262ccd8409
branches: trunk
changeset: 763853:49262ccd8409
user: jmmv <jmmv%NetBSD.org@localhost>
date: Tue Apr 05 17:17:35 2011 +0000
description:
Pull up revision b94e200f2a6ce3d47103339db1f3c8936b7238d3:
Unset TERM when running GDB
GDB inserts some funny control characters in its output when TERM is set to
e.g. xterm. Workaround this by simply unsetting TERM.
Reported by martin@ and diagnosed by pooka@/martin@.
diffstat:
external/bsd/atf/dist/atf-c++/detail/process.hpp | 28 ++++++++++++-----
external/bsd/atf/dist/atf-c/detail/process.c | 16 +++++++---
external/bsd/atf/dist/atf-c/detail/process.h | 8 +++-
external/bsd/atf/dist/atf-c/detail/process_test.c | 35 +++++++++++++++++++---
external/bsd/atf/dist/atf-run/atf-run.cpp | 15 +++++++++-
5 files changed, 78 insertions(+), 24 deletions(-)
diffs (truncated from 318 to 300 lines):
diff -r 24fb70e65413 -r 49262ccd8409 external/bsd/atf/dist/atf-c++/detail/process.hpp
--- a/external/bsd/atf/dist/atf-c++/detail/process.hpp Tue Apr 05 16:37:06 2011 +0000
+++ b/external/bsd/atf/dist/atf-c++/detail/process.hpp Tue Apr 05 17:17:35 2011 +0000
@@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
-// Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc.
+// Copyright (c) 2008, 2009, 2010, 2011 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -118,7 +118,7 @@
child fork(void (*)(void*), const OutStream&, const ErrStream&, void*);
template< class OutStream, class ErrStream > friend
status exec(const atf::fs::path&, const argv_array&,
- const OutStream&, const ErrStream&);
+ const OutStream&, const ErrStream&, void (*)(void));
public:
stream_capture(void);
@@ -130,7 +130,7 @@
child fork(void (*)(void*), const OutStream&, const ErrStream&, void*);
template< class OutStream, class ErrStream > friend
status exec(const atf::fs::path&, const argv_array&,
- const OutStream&, const ErrStream&);
+ const OutStream&, const ErrStream&, void (*)(void));
public:
stream_connect(const int, const int);
@@ -142,7 +142,7 @@
child fork(void (*)(void*), const OutStream&, const ErrStream&, void*);
template< class OutStream, class ErrStream > friend
status exec(const atf::fs::path&, const argv_array&,
- const OutStream&, const ErrStream&);
+ const OutStream&, const ErrStream&, void (*)(void));
public:
stream_inherit(void);
@@ -154,7 +154,7 @@
child fork(void (*)(void*), const OutStream&, const ErrStream&, void*);
template< class OutStream, class ErrStream > friend
status exec(const atf::fs::path&, const argv_array&,
- const OutStream&, const ErrStream&);
+ const OutStream&, const ErrStream&, void (*)(void));
public:
stream_redirect_fd(const int);
@@ -166,7 +166,7 @@
child fork(void (*)(void*), const OutStream&, const ErrStream&, void*);
template< class OutStream, class ErrStream > friend
status exec(const atf::fs::path&, const argv_array&,
- const OutStream&, const ErrStream&);
+ const OutStream&, const ErrStream&, void (*)(void));
public:
stream_redirect_path(const fs::path&);
@@ -182,7 +182,7 @@
friend class child;
template< class OutStream, class ErrStream > friend
status exec(const atf::fs::path&, const argv_array&,
- const OutStream&, const ErrStream&);
+ const OutStream&, const ErrStream&, void (*)(void));
status(atf_process_status_t&);
@@ -249,7 +249,8 @@
template< class OutStream, class ErrStream >
status
exec(const atf::fs::path& prog, const argv_array& argv,
- const OutStream& outsb, const ErrStream& errsb)
+ const OutStream& outsb, const ErrStream& errsb,
+ void (*prehook)(void))
{
atf_process_status_t s;
@@ -257,13 +258,22 @@
atf_error_t err = atf_process_exec_array(&s, prog.c_path(),
argv.exec_argv(),
outsb.get_sb(),
- errsb.get_sb());
+ errsb.get_sb(),
+ prehook);
if (atf_is_error(err))
throw_atf_error(err);
return status(s);
}
+template< class OutStream, class ErrStream >
+status
+exec(const atf::fs::path& prog, const argv_array& argv,
+ const OutStream& outsb, const ErrStream& errsb)
+{
+ return exec(prog, argv, outsb, errsb, NULL);
+}
+
} // namespace process
} // namespace atf
diff -r 24fb70e65413 -r 49262ccd8409 external/bsd/atf/dist/atf-c/detail/process.c
--- a/external/bsd/atf/dist/atf-c/detail/process.c Tue Apr 05 16:37:06 2011 +0000
+++ b/external/bsd/atf/dist/atf-c/detail/process.c Tue Apr 05 17:17:35 2011 +0000
@@ -1,7 +1,7 @@
/*
* Automated Testing Framework (atf)
*
- * Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
+ * Copyright (c) 2007, 2008, 2009, 2010, 2011 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -592,6 +592,7 @@
struct exec_args {
const atf_fs_path_t *m_prog;
const char *const *m_argv;
+ void (*m_prehook)(void);
};
static
@@ -600,6 +601,9 @@
{
struct exec_args *ea = v;
+ if (ea->m_prehook != NULL)
+ ea->m_prehook();
+
const int ret = const_execvp(atf_fs_path_cstring(ea->m_prog), ea->m_argv);
const int errnocopy = errno;
INV(ret == -1);
@@ -613,11 +617,12 @@
const atf_fs_path_t *prog,
const char *const *argv,
const atf_process_stream_t *outsb,
- const atf_process_stream_t *errsb)
+ const atf_process_stream_t *errsb,
+ void (*prehook)(void))
{
atf_error_t err;
atf_process_child_t c;
- struct exec_args ea = { prog, argv };
+ struct exec_args ea = { prog, argv, prehook };
PRE(outsb == NULL ||
atf_process_stream_type(outsb) != atf_process_stream_type_capture);
@@ -645,7 +650,8 @@
const atf_fs_path_t *prog,
const atf_list_t *argv,
const atf_process_stream_t *outsb,
- const atf_process_stream_t *errsb)
+ const atf_process_stream_t *errsb,
+ void (*prehook)(void))
{
atf_error_t err;
const char **argv2;
@@ -660,7 +666,7 @@
if (atf_is_error(err))
goto out;
- err = atf_process_exec_array(s, prog, argv2, outsb, errsb);
+ err = atf_process_exec_array(s, prog, argv2, outsb, errsb, prehook);
free(argv2);
out:
diff -r 24fb70e65413 -r 49262ccd8409 external/bsd/atf/dist/atf-c/detail/process.h
--- a/external/bsd/atf/dist/atf-c/detail/process.h Tue Apr 05 16:37:06 2011 +0000
+++ b/external/bsd/atf/dist/atf-c/detail/process.h Tue Apr 05 17:17:35 2011 +0000
@@ -1,7 +1,7 @@
/*
* Automated Testing Framework (atf)
*
- * Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -124,11 +124,13 @@
const atf_fs_path_t *,
const char *const *,
const atf_process_stream_t *,
- const atf_process_stream_t *);
+ const atf_process_stream_t *,
+ void (*)(void));
atf_error_t atf_process_exec_list(atf_process_status_t *,
const atf_fs_path_t *,
const atf_list_t *,
const atf_process_stream_t *,
- const atf_process_stream_t *);
+ const atf_process_stream_t *,
+ void (*)(void));
#endif /* !defined(ATF_C_PROCESS_H) */
diff -r 24fb70e65413 -r 49262ccd8409 external/bsd/atf/dist/atf-c/detail/process_test.c
--- a/external/bsd/atf/dist/atf-c/detail/process_test.c Tue Apr 05 16:37:06 2011 +0000
+++ b/external/bsd/atf/dist/atf-c/detail/process_test.c Tue Apr 05 17:17:35 2011 +0000
@@ -1,7 +1,7 @@
/*
* Automated Testing Framework (atf)
*
- * Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -861,7 +861,8 @@
static
void
-do_exec(const atf_tc_t *tc, const char *helper_name, atf_process_status_t *s)
+do_exec(const atf_tc_t *tc, const char *helper_name, atf_process_status_t *s,
+ void (*prehook)(void))
{
atf_fs_path_t process_helpers;
const char *argv[3];
@@ -873,7 +874,7 @@
argv[2] = NULL;
printf("Executing %s %s\n", argv[0], argv[1]);
- RE(atf_process_exec_array(s, &process_helpers, argv, NULL, NULL));
+ RE(atf_process_exec_array(s, &process_helpers, argv, NULL, NULL, prehook));
atf_fs_path_fini(&process_helpers);
}
@@ -902,7 +903,7 @@
{
atf_process_status_t status;
- do_exec(tc, "exit-failure", &status);
+ do_exec(tc, "exit-failure", &status, NULL);
ATF_CHECK(atf_process_status_exited(&status));
ATF_CHECK_EQ(atf_process_status_exitstatus(&status), EXIT_FAILURE);
atf_process_status_fini(&status);
@@ -932,7 +933,7 @@
RE(atf_fs_path_init_fmt(&outpath, "stdout"));
RE(atf_process_stream_init_redirect_path(&outsb, &outpath));
RE(atf_process_exec_list(&status, &process_helpers, &argv, &outsb,
- NULL));
+ NULL, NULL));
atf_process_stream_fini(&outsb);
atf_fs_path_fini(&outpath);
}
@@ -952,6 +953,27 @@
atf_fs_path_fini(&process_helpers);
}
+static void
+exit_early(void)
+{
+ exit(80);
+}
+
+ATF_TC(exec_prehook);
+ATF_TC_HEAD(exec_prehook, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Tests execing a command with a prehook");
+}
+ATF_TC_BODY(exec_prehook, tc)
+{
+ atf_process_status_t status;
+
+ do_exec(tc, "exit-success", &status, exit_early);
+ ATF_CHECK(atf_process_status_exited(&status));
+ ATF_CHECK_EQ(atf_process_status_exitstatus(&status), 80);
+ atf_process_status_fini(&status);
+}
+
ATF_TC(exec_success);
ATF_TC_HEAD(exec_success, tc)
{
@@ -961,7 +983,7 @@
{
atf_process_status_t status;
- do_exec(tc, "exit-success", &status);
+ do_exec(tc, "exit-success", &status, NULL);
ATF_CHECK(atf_process_status_exited(&status));
ATF_CHECK_EQ(atf_process_status_exitstatus(&status), EXIT_SUCCESS);
atf_process_status_fini(&status);
@@ -1104,6 +1126,7 @@
/* Add the tests for the free functions. */
ATF_TP_ADD_TC(tp, exec_failure);
ATF_TP_ADD_TC(tp, exec_list);
+ ATF_TP_ADD_TC(tp, exec_prehook);
ATF_TP_ADD_TC(tp, exec_success);
ATF_TP_ADD_TC(tp, fork_cookie);
ATF_TP_ADD_TC(tp, fork_out_capture_err_capture);
diff -r 24fb70e65413 -r 49262ccd8409 external/bsd/atf/dist/atf-run/atf-run.cpp
--- a/external/bsd/atf/dist/atf-run/atf-run.cpp Tue Apr 05 16:37:06 2011 +0000
+++ b/external/bsd/atf/dist/atf-run/atf-run.cpp Tue Apr 05 17:17:35 2011 +0000
@@ -100,6 +100,18 @@
};
static void
+sanitize_gdb_env(void)
+{
+ try {
+ atf::env::unset("TERM");
+ } catch (...) {
+ // Just swallow exceptions here; they cannot propagate into C, which
+ // is where this function is called from, and even if these exceptions
Home |
Main Index |
Thread Index |
Old Index