/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include #include #include #include #include #include #include using namespace ::osl; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::uno; namespace { class TestInterfaceContainer3 : public CppUnit::TestFixture { public: void test1(); CPPUNIT_TEST_SUITE(TestInterfaceContainer3); CPPUNIT_TEST(test1); CPPUNIT_TEST_SUITE_END(); }; class TestListener : public cppu::WeakImplHelper { public: // Methods virtual void SAL_CALL disposing(const css::lang::EventObject& /*Source*/) override {} virtual void SAL_CALL vetoableChange(const css::beans::PropertyChangeEvent& /*aEvent*/) override { } }; void TestInterfaceContainer3::test1() { Mutex mutex; { comphelper::OInterfaceContainerHelper3 helper(mutex); Reference r1 = new TestListener; Reference r2 = new TestListener; Reference r3 = new TestListener; helper.addInterface(r1); helper.addInterface(r2); helper.addInterface(r3); helper.disposeAndClear(EventObject()); } { comphelper::OInterfaceContainerHelper3 helper(mutex); Reference r1 = new TestListener; Reference r2 = new TestListener; Reference r3 = new TestListener; helper.addInterface(r1); helper.addInterface(r2); helper.addInterface(r3); comphelper::OInterfaceIteratorHelper3 iterator(helper); while (iterator.hasMoreElements()) iterator.next()->vetoableChange(PropertyChangeEvent()); helper.disposeAndClear(EventObject()); } { comphelper::OInterfaceContainerHelper3 helper(mutex); Reference r1 = new TestListener; Reference r2 = new TestListener; Reference r3 = new TestListener; helper.addInterface(r1); helper.addInterface(r2); helper.addInterface(r3); comphelper::OInterfaceIteratorHelper3 iterator(helper); iterator.next()->vetoableChange(PropertyChangeEvent()); iterator.remove(); iterator.next()->vetoableChange(PropertyChangeEvent()); iterator.remove(); iterator.next()->vetoableChange(PropertyChangeEvent()); iterator.remove(); CPPUNIT_ASSERT_EQUAL(static_cast(0), helper.getLength()); helper.disposeAndClear(EventObject()); } { comphelper::OInterfaceContainerHelper3 helper(mutex); Reference r1 = new TestListener; Reference r2 = new TestListener; Reference r3 = new TestListener; helper.addInterface(r1); helper.addInterface(r2); helper.addInterface(r3); { comphelper::OInterfaceIteratorHelper3 iterator(helper); while (iterator.hasMoreElements()) { Reference r = iterator.next(); if (r == r1) iterator.remove(); } } CPPUNIT_ASSERT_EQUAL(static_cast(2), helper.getLength()); { comphelper::OInterfaceIteratorHelper3 iterator(helper); while (iterator.hasMoreElements()) { Reference r = iterator.next(); CPPUNIT_ASSERT(r != r1); CPPUNIT_ASSERT(r == r2 || r == r3); } } helper.disposeAndClear(EventObject()); } { comphelper::OInterfaceContainerHelper3 helper(mutex); Reference r1 = new TestListener; helper.addInterface(r1); { comphelper::OInterfaceIteratorHelper3 iterator(helper); iterator.next(); iterator.remove(); } CPPUNIT_ASSERT_EQUAL(static_cast(0), helper.getLength()); } } CPPUNIT_TEST_SUITE_REGISTRATION(TestInterfaceContainer3); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ lue='distro/collabora/lov-6.0.5'>distro/collabora/lov-6.0.5 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-12-25oss-fuzz: use fuzzer_statics for default staticsJan-Marek Glogowski
Change-Id: I3616507127e0661635d87ba2b949ddaa13bc898d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127454 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2021-02-28Upgrade fuzzers to LIB_FUZZING_ENGINEAndrzej Hunt
And check that LIB_FUZZING_ENGINE is set during configure. Because: 1. It's easier to build locally this way (you don't need to build or hack a libFuzzingEngine.a - instead you can just specify LIB_FUZZING_ENGINE=-fsanitize=fuzzer to produce a valid build). 2. Using -lFuzzingEngine is deprecated [1] for various reasons [2]. The old behaviour can be emulated if desired by setting LIB_FUZZING_ENGINE=-lFuzzingEngine . This patch was tested as follows: - Building LO within oss-fuzz via: python infra/helper.py build_fuzzers --sanitizer address libreoffice </path/to/patched-libreoffice-core> python infra/helper.py check_build libreoffice - Building LO fuzzers standalone via: export CC="clang-11" export CXX="clang++-11 -stdlib=libc++" export CFLAGS="-fsanitize=address -fsanitize-address-use-after-scope -fsanitize=fuzzer-no-link -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION" export CXXFLAGS="$CFLAGS -stdlib=libc++" export LDFLAGS="$CFLAGS -Wl,--compress-debug-sections,zlib -lpthread" export LIB_FUZZING_ENGINE=-fsanitize=fuzzer ./autogen.sh --with-distro=LibreOfficeOssFuzz --with-system-libxml make fuzzers (--with-system-libxml only appears to be needed because of issues specific to my build environment/Suse 15.2. I'm invoking clang-11 simply because that's the most modern clang I have installed, plain clang should also work on most sufficiently modern systems). [1] https://github.com/google/oss-fuzz/blob/481280c65048fd12fb2141b9225af511a9ef7ed2/infra/presubmit.py#L46 [2] https://github.com/google/oss-fuzz/issues/2164 Change-Id: Iddb577c30a39620e72372ef6c2d3fda67f8aabdf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111691 Tested-by: Jenkins Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2017-10-20shrink ww8 fuzzerCaolán McNamara
Change-Id: Ic2ee596b1d2dbba4f685100aef1862ce0e5e435d
2017-06-11refactor fuzzer army a bitCaolán McNamara
the core lib has grown sufficiently large that the fuzzing tooling complains of too many instrumented conditions so split things up to hopefully fit again Change-Id: I58899d143925f958aec95b5f213c2dc75a6686ec Reviewed-on: https://gerrit.libreoffice.org/38647 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2017-06-01add ww8 fuzzerCaolán McNamara
Change-Id: Icb8b385e3c59b6476ac58da5e76bbe73eaa82d88