Date: Tue, 03 Sep 2019 14:06:06 -0000 From: Enji Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345771 - in projects/capsicum-test: contrib/bsnmp/snmpd contrib/googletest/googletest/test lib/libbe sbin/bectl/tests sys/arm/broadcom/bcm2835 sys/dev/md sys/dev/usb/wlan tests/sys/audit Message-ID: <201904011809.x31I9RsI062962@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Mon Apr 1 18:09:26 2019 New Revision: 345771 URL: https://svnweb.freebsd.org/changeset/base/345771 Log: MFhead@r345770 Replaced: projects/capsicum-test/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc - copied unchanged from r345770, head/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc Modified: projects/capsicum-test/contrib/bsnmp/snmpd/trap.c projects/capsicum-test/lib/libbe/be.c projects/capsicum-test/sbin/bectl/tests/bectl_test.sh projects/capsicum-test/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c projects/capsicum-test/sys/dev/md/md.c projects/capsicum-test/sys/dev/usb/wlan/if_run.c projects/capsicum-test/sys/dev/usb/wlan/if_uath.c projects/capsicum-test/sys/dev/usb/wlan/if_urtw.c projects/capsicum-test/tests/sys/audit/Makefile projects/capsicum-test/tests/sys/audit/process-control.c Directory Properties: projects/capsicum-test/ (props changed) Modified: projects/capsicum-test/contrib/bsnmp/snmpd/trap.c ============================================================================== --- projects/capsicum-test/contrib/bsnmp/snmpd/trap.c Mon Apr 1 18:07:48 2019 (r345770) +++ projects/capsicum-test/contrib/bsnmp/snmpd/trap.c Mon Apr 1 18:09:26 2019 (r345771) @@ -726,8 +726,7 @@ target_activate_address(struct target_address *addrs) sa.sin_addr.s_addr = htonl((addrs->address[0] << 24) | (addrs->address[1] << 16) | (addrs->address[2] << 8) | (addrs->address[3] << 0)); - sa.sin_port = htons(addrs->address[4]) << 8 | - htons(addrs->address[5]) << 0; + sa.sin_port = htons(addrs->address[4] << 8 | addrs->address[5]); if (connect(addrs->socket, (struct sockaddr *)&sa, sa.sin_len) == -1) { syslog(LOG_ERR, "connect(%s,%u): %m", Copied: projects/capsicum-test/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc (from r345770, head/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/capsicum-test/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc Mon Apr 1 18:09:26 2019 (r345771, copy of r345770, head/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc) @@ -0,0 +1,60 @@ +// Copyright 2019, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// This test verifies that skipping in the environment results in the +// testcases being skipped. +// +// This is a reproduction case for +// https://github.com/google/googletest/issues/2189 . + +#include <iostream> +#include <gtest/gtest.h> + +class SetupEnvironment : public testing::Environment { +public: + void SetUp() override { + GTEST_SKIP() << "Skipping the entire environment"; + } +}; + +TEST(Test, AlwaysPasses) { + EXPECT_EQ(true, true); +} + +TEST(Test, AlwaysFails) { + EXPECT_EQ(true, false); +} + +int main(int argc, char **argv) { + testing::InitGoogleTest(&argc, argv); + + testing::AddGlobalTestEnvironment(new SetupEnvironment()); + + return (RUN_ALL_TESTS()); +} Modified: projects/capsicum-test/lib/libbe/be.c ============================================================================== --- projects/capsicum-test/lib/libbe/be.c Mon Apr 1 18:07:48 2019 (r345770) +++ projects/capsicum-test/lib/libbe/be.c Mon Apr 1 18:09:26 2019 (r345771) @@ -265,6 +265,16 @@ be_destroy(libbe_handle_t *lbh, const char *name, int zfs_prop_get(fs, ZFS_PROP_ORIGIN, origin, sizeof(origin), NULL, NULL, 0, 1) != 0) return (set_error(lbh, BE_ERR_NOORIGIN)); + + /* Don't destroy a mounted dataset unless force is specified */ + if ((mounted = zfs_is_mounted(fs, NULL)) != 0) { + if (force) { + zfs_unmount(fs, NULL, 0); + } else { + free(bdd.snapname); + return (set_error(lbh, BE_ERR_DESTROYMNT)); + } + } } else { if (!zfs_dataset_exists(lbh->lzh, path, ZFS_TYPE_SNAPSHOT)) return (set_error(lbh, BE_ERR_NOENT)); @@ -277,16 +287,6 @@ be_destroy(libbe_handle_t *lbh, const char *name, int if (fs == NULL) { free(bdd.snapname); return (set_error(lbh, BE_ERR_ZFSOPEN)); - } - } - - /* Check if mounted, unmount if force is specified */ - if ((mounted = zfs_is_mounted(fs, NULL)) != 0) { - if (force) { - zfs_unmount(fs, NULL, 0); - } else { - free(bdd.snapname); - return (set_error(lbh, BE_ERR_DESTROYMNT)); } } Modified: projects/capsicum-test/sbin/bectl/tests/bectl_test.sh ============================================================================== --- projects/capsicum-test/sbin/bectl/tests/bectl_test.sh Mon Apr 1 18:07:48 2019 (r345770) +++ projects/capsicum-test/sbin/bectl/tests/bectl_test.sh Mon Apr 1 18:09:26 2019 (r345771) @@ -123,12 +123,21 @@ bectl_destroy_body() zpool=$(make_zpool_name) disk=${cwd}/disk.img mount=${cwd}/mnt + root=${mount}/root bectl_create_setup ${zpool} ${disk} ${mount} atf_check bectl -r ${zpool}/ROOT create -e default default2 atf_check -o not-empty zfs get mountpoint ${zpool}/ROOT/default2 atf_check -e ignore bectl -r ${zpool}/ROOT destroy default2 atf_check -e not-empty -s not-exit:0 zfs get mountpoint ${zpool}/ROOT/default2 + + # Test origin snapshot deletion when the snapshot to be destroyed + # belongs to a mounted dataset, see PR 236043. + atf_check mkdir -p ${root} + atf_check -o not-empty bectl -r ${zpool}/ROOT mount default ${root} + atf_check bectl -r ${zpool}/ROOT create -e default default3 + atf_check bectl -r ${zpool}/ROOT destroy -o default3 + atf_check bectl -r ${zpool}/ROOT unmount default } bectl_destroy_cleanup() { Modified: projects/capsicum-test/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c ============================================================================== --- projects/capsicum-test/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Mon Apr 1 18:07:48 2019 (r345770) +++ projects/capsicum-test/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Mon Apr 1 18:09:26 2019 (r345771) @@ -66,8 +66,17 @@ __FBSDID("$FreeBSD$"); #define NUM_DMA_SEGS 2 #ifdef DEBUG -#define dprintf(fmt, args...) do { printf("%s(): ", __func__); \ - printf(fmt,##args); } while (0) +static int bcm2835_sdhci_debug = 0; + +TUNABLE_INT("hw.bcm2835.sdhci.debug", &bcm2835_sdhci_debug); +SYSCTL_INT(_hw_sdhci, OID_AUTO, bcm2835_sdhci_debug, CTLFLAG_RWTUN, + &bcm2835_sdhci_debug, 0, "bcm2835 SDHCI debug level"); + +#define dprintf(fmt, args...) \ + do { \ + if (bcm2835_sdhci_debug) \ + printf("%s: " fmt, __func__, ##args); \ + } while (0) #else #define dprintf(fmt, args...) #endif Modified: projects/capsicum-test/sys/dev/md/md.c ============================================================================== --- projects/capsicum-test/sys/dev/md/md.c Mon Apr 1 18:07:48 2019 (r345770) +++ projects/capsicum-test/sys/dev/md/md.c Mon Apr 1 18:09:26 2019 (r345771) @@ -110,6 +110,7 @@ #define MD_SHUTDOWN 0x10000 /* Tell worker thread to terminate. */ #define MD_EXITING 0x20000 /* Worker thread is exiting. */ +#define MD_PROVIDERGONE 0x40000 /* Safe to free the softc */ #ifndef MD_NSECT #define MD_NSECT (10000 * 2) @@ -199,6 +200,7 @@ static g_start_t g_md_start; static g_access_t g_md_access; static void g_md_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g_consumer *cp __unused, struct g_provider *pp); +static g_provgone_t g_md_providergone; static struct cdev *status_dev = NULL; static struct sx md_sx; @@ -220,6 +222,7 @@ struct g_class g_md_class = { .start = g_md_start, .access = g_md_access, .dumpconf = g_md_dumpconf, + .providergone = g_md_providergone, }; DECLARE_GEOM_CLASS(g_md_class, g_md); @@ -481,8 +484,8 @@ g_md_start(struct bio *bp) } mtx_lock(&sc->queue_mtx); bioq_disksort(&sc->bio_queue, bp); - mtx_unlock(&sc->queue_mtx); wakeup(sc); + mtx_unlock(&sc->queue_mtx); } #define MD_MALLOC_MOVE_ZERO 1 @@ -1496,17 +1499,30 @@ bad: return (error); } +static void +g_md_providergone(struct g_provider *pp) +{ + struct md_s *sc = pp->geom->softc; + + mtx_lock(&sc->queue_mtx); + sc->flags |= MD_PROVIDERGONE; + wakeup(&sc->flags); + mtx_unlock(&sc->queue_mtx); +} + static int mddestroy(struct md_s *sc, struct thread *td) { if (sc->gp) { - sc->gp->softc = NULL; g_topology_lock(); g_wither_geom(sc->gp, ENXIO); g_topology_unlock(); - sc->gp = NULL; - sc->pp = NULL; + + mtx_lock(&sc->queue_mtx); + while (!(sc->flags & MD_PROVIDERGONE)) + msleep(&sc->flags, &sc->queue_mtx, PRIBIO, "mddestroy", 0); + mtx_unlock(&sc->queue_mtx); } if (sc->devstat) { devstat_remove_entry(sc->devstat); Modified: projects/capsicum-test/sys/dev/usb/wlan/if_run.c ============================================================================== --- projects/capsicum-test/sys/dev/usb/wlan/if_run.c Mon Apr 1 18:07:48 2019 (r345770) +++ projects/capsicum-test/sys/dev/usb/wlan/if_run.c Mon Apr 1 18:09:26 2019 (r345771) @@ -2851,10 +2851,6 @@ run_rx_frame(struct run_softc *sc, struct mbuf *m, uin } if (flags & RT2860_RX_L2PAD) { - /* - * XXX OpenBSD removes padding between header - * and payload here... - */ RUN_DPRINTF(sc, RUN_DEBUG_RECV, "received RT2860_RX_L2PAD frame\n"); len += 2; @@ -2865,8 +2861,8 @@ run_rx_frame(struct run_softc *sc, struct mbuf *m, uin wh = mtod(m, struct ieee80211_frame *); - /* XXX wrong for monitor mode */ - if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { + if ((wh->i_fc[1] & IEEE80211_FC1_PROTECTED) != 0 && + (flags & RT2860_RX_DEC) != 0) { wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED; m->m_flags |= M_WEP; } @@ -2896,6 +2892,8 @@ run_rx_frame(struct run_softc *sc, struct mbuf *m, uin uint16_t phy; tap->wr_flags = 0; + if (flags & RT2860_RX_L2PAD) + tap->wr_flags |= IEEE80211_RADIOTAP_F_DATAPAD; tap->wr_antsignal = rssi; tap->wr_antenna = ant; tap->wr_dbm_antsignal = run_rssi2dbm(sc, rssi, ant); @@ -3162,14 +3160,23 @@ tr_setup: vap = data->ni->ni_vap; if (ieee80211_radiotap_active_vap(vap)) { + const struct ieee80211_frame *wh; struct run_tx_radiotap_header *tap = &sc->sc_txtap; struct rt2860_txwi *txwi = (struct rt2860_txwi *)(&data->desc + sizeof(struct rt2870_txd)); + int has_l2pad; + + wh = mtod(m, struct ieee80211_frame *); + has_l2pad = IEEE80211_HAS_ADDR4(wh) != + IEEE80211_QOS_HAS_SEQ(wh); + tap->wt_flags = 0; tap->wt_rate = rt2860_rates[data->ridx].rate; tap->wt_hwqueue = index; if (le16toh(txwi->phy) & RT2860_PHY_SHPRE) tap->wt_flags |= IEEE80211_RADIOTAP_F_SHORTPRE; + if (has_l2pad) + tap->wt_flags |= IEEE80211_RADIOTAP_F_DATAPAD; ieee80211_radiotap_tx(vap, m); } Modified: projects/capsicum-test/sys/dev/usb/wlan/if_uath.c ============================================================================== --- projects/capsicum-test/sys/dev/usb/wlan/if_uath.c Mon Apr 1 18:07:48 2019 (r345770) +++ projects/capsicum-test/sys/dev/usb/wlan/if_uath.c Mon Apr 1 18:09:26 2019 (r345771) @@ -1276,8 +1276,8 @@ uath_watchdog(void *arg) if (sc->sc_tx_timer > 0) { if (--sc->sc_tx_timer == 0) { device_printf(sc->sc_dev, "device timeout\n"); - /*uath_init(sc); XXX needs a process context! */ counter_u64_add(ic->ic_oerrors, 1); + ieee80211_restart_all(ic); return; } callout_reset(&sc->watchdog_ch, hz, uath_watchdog, sc); Modified: projects/capsicum-test/sys/dev/usb/wlan/if_urtw.c ============================================================================== --- projects/capsicum-test/sys/dev/usb/wlan/if_urtw.c Mon Apr 1 18:07:48 2019 (r345770) +++ projects/capsicum-test/sys/dev/usb/wlan/if_urtw.c Mon Apr 1 18:09:26 2019 (r345771) @@ -1891,11 +1891,13 @@ static void urtw_watchdog(void *arg) { struct urtw_softc *sc = arg; + struct ieee80211com *ic = &sc->sc_ic; if (sc->sc_txtimer > 0) { if (--sc->sc_txtimer == 0) { device_printf(sc->sc_dev, "device timeout\n"); - counter_u64_add(sc->sc_ic.ic_oerrors, 1); + counter_u64_add(ic->ic_oerrors, 1); + ieee80211_restart_all(ic); return; } callout_reset(&sc->sc_watchdog_ch, hz, urtw_watchdog, sc); Modified: projects/capsicum-test/tests/sys/audit/Makefile ============================================================================== --- projects/capsicum-test/tests/sys/audit/Makefile Mon Apr 1 18:07:48 2019 (r345770) +++ projects/capsicum-test/tests/sys/audit/Makefile Mon Apr 1 18:09:26 2019 (r345771) @@ -55,4 +55,6 @@ WARNS?= 6 LDFLAGS+= -lbsm -lutil +CFLAGS.process-control.c+= -I${SRCTOP}/tests + .include <bsd.test.mk> Modified: projects/capsicum-test/tests/sys/audit/process-control.c ============================================================================== --- projects/capsicum-test/tests/sys/audit/process-control.c Mon Apr 1 18:07:48 2019 (r345770) +++ projects/capsicum-test/tests/sys/audit/process-control.c Mon Apr 1 18:09:26 2019 (r345771) @@ -48,6 +48,8 @@ #include "utils.h" +#include "freebsd_test_suite/macros.h" + static pid_t pid; static int filedesc, status; static struct pollfd fds[1]; @@ -1512,15 +1514,8 @@ ATF_TC_HEAD(cap_enter_success, tc) ATF_TC_BODY(cap_enter_success, tc) { - int capinfo; - size_t len = sizeof(capinfo); - const char *capname = "kern.features.security_capability_mode"; - ATF_REQUIRE_EQ(0, sysctlbyname(capname, &capinfo, &len, NULL, 0)); + ATF_REQUIRE_FEATURE("security_capability_mode"); - /* Without CAPABILITY_MODE enabled, cap_enter() returns ENOSYS */ - if (!capinfo) - atf_tc_skip("Capsicum is not enabled in the system"); - FILE *pipefd = setup(fds, auclass); ATF_REQUIRE((pid = fork()) != -1); if (pid) { @@ -1550,14 +1545,9 @@ ATF_TC_HEAD(cap_getmode_success, tc) ATF_TC_BODY(cap_getmode_success, tc) { - int capinfo, modep; - size_t len = sizeof(capinfo); - const char *capname = "kern.features.security_capability_mode"; - ATF_REQUIRE_EQ(0, sysctlbyname(capname, &capinfo, &len, NULL, 0)); + int modep; - /* Without CAPABILITY_MODE enabled, cap_getmode() returns ENOSYS */ - if (!capinfo) - atf_tc_skip("Capsicum is not enabled in the system"); + ATF_REQUIRE_FEATURE("security_capability_mode"); pid = getpid(); snprintf(pcregex, sizeof(pcregex), "cap_getmode.*%d.*success", pid);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904011809.x31I9RsI062962>