Module Name: src Committed By: jmmv Date: Tue Apr 5 17:17:35 UTC 2011
Modified Files: src/external/bsd/atf/dist/atf-c++/detail: process.hpp src/external/bsd/atf/dist/atf-c/detail: process.c process.h process_test.c src/external/bsd/atf/dist/atf-run: atf-run.cpp Log Message: 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@. To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r1.2 \ src/external/bsd/atf/dist/atf-c++/detail/process.hpp cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/atf/dist/atf-c/detail/process.c \ src/external/bsd/atf/dist/atf-c/detail/process.h cvs rdiff -u -r1.1.1.2 -r1.2 \ src/external/bsd/atf/dist/atf-c/detail/process_test.c cvs rdiff -u -r1.10 -r1.11 src/external/bsd/atf/dist/atf-run/atf-run.cpp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/bsd/atf/dist/atf-c++/detail/process.hpp diff -u src/external/bsd/atf/dist/atf-c++/detail/process.hpp:1.1.1.1 src/external/bsd/atf/dist/atf-c++/detail/process.hpp:1.2 --- src/external/bsd/atf/dist/atf-c++/detail/process.hpp:1.1.1.1 Wed Oct 20 09:14:21 2010 +++ src/external/bsd/atf/dist/atf-c++/detail/process.hpp Tue Apr 5 17:17:35 2011 @@ -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 Index: src/external/bsd/atf/dist/atf-c/detail/process.c diff -u src/external/bsd/atf/dist/atf-c/detail/process.c:1.1.1.1 src/external/bsd/atf/dist/atf-c/detail/process.c:1.2 --- src/external/bsd/atf/dist/atf-c/detail/process.c:1.1.1.1 Wed Oct 20 09:14:19 2010 +++ src/external/bsd/atf/dist/atf-c/detail/process.c Tue Apr 5 17:17:35 2011 @@ -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: Index: src/external/bsd/atf/dist/atf-c/detail/process.h diff -u src/external/bsd/atf/dist/atf-c/detail/process.h:1.1.1.1 src/external/bsd/atf/dist/atf-c/detail/process.h:1.2 --- src/external/bsd/atf/dist/atf-c/detail/process.h:1.1.1.1 Wed Oct 20 09:14:19 2010 +++ src/external/bsd/atf/dist/atf-c/detail/process.h Tue Apr 5 17:17:35 2011 @@ -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) */ Index: src/external/bsd/atf/dist/atf-c/detail/process_test.c diff -u src/external/bsd/atf/dist/atf-c/detail/process_test.c:1.1.1.2 src/external/bsd/atf/dist/atf-c/detail/process_test.c:1.2 --- src/external/bsd/atf/dist/atf-c/detail/process_test.c:1.1.1.2 Sun Nov 7 17:43:24 2010 +++ src/external/bsd/atf/dist/atf-c/detail/process_test.c Tue Apr 5 17:17:35 2011 @@ -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); Index: src/external/bsd/atf/dist/atf-run/atf-run.cpp diff -u src/external/bsd/atf/dist/atf-run/atf-run.cpp:1.10 src/external/bsd/atf/dist/atf-run/atf-run.cpp:1.11 --- src/external/bsd/atf/dist/atf-run/atf-run.cpp:1.10 Thu Mar 31 16:44:17 2011 +++ src/external/bsd/atf/dist/atf-run/atf-run.cpp Tue Apr 5 17:17:35 2011 @@ -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 + // appear they are benign. + } +} + +static void dump_stacktrace(const atf::fs::path& tp, const atf::process::status& s, const atf::fs::path& workdir, impl::atf_tps_writer& w) { @@ -121,7 +133,8 @@ atf::process::status status = atf::process::exec( gdb, args, atf::process::stream_redirect_path(gdbout), - atf::process::stream_redirect_path(atf::fs::path("/dev/null"))); + atf::process::stream_redirect_path(atf::fs::path("/dev/null")), + sanitize_gdb_env); if (!status.exited() || status.exitstatus() != EXIT_SUCCESS) { w.stderr_tc("Execution of " GDB " failed"); return;