Changeset 201928 in webkit


Ignore:
Timestamp:
Jun 10, 2016 10:04:11 AM (8 years ago)
Author:
beidson@apple.com
Message:

WTF_CrossThreadTask.Basic fails in all non mac ports.
https://bugs.webkit.org/show_bug.cgi?id=158612

Reviewed by Alex Christensen.

The test is very sensitive to argument evaluation order which is explicitly undefined in C++.

Instead, we should just count the appropriate events to forget their order.

  • TestWebKitAPI/Tests/WTF/CrossThreadTask.cpp:

(TestWebKitAPI::LifetimeLogger::LifetimeLogger):
(TestWebKitAPI::LifetimeLogger::~LifetimeLogger):
(TestWebKitAPI::LifetimeLogger::isolatedCopy):
(TestWebKitAPI::LifetimeLogger::fullName):
(TestWebKitAPI::testFunction):
(TestWebKitAPI::TEST):
(TestWebKitAPI::LifetimeLogger::log): Deleted.
(TestWebKitAPI::LifetimeLogger::takeLogStr): Deleted.

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r201914 r201928  
     12016-06-10  Brady Eidson  <beidson@apple.com>
     2
     3        WTF_CrossThreadTask.Basic fails in all non mac ports.
     4        https://bugs.webkit.org/show_bug.cgi?id=158612
     5
     6        Reviewed by Alex Christensen.
     7
     8        The test is very sensitive to argument evaluation order which is explicitly undefined in C++.
     9       
     10        Instead, we should just count the appropriate events to forget their order.
     11       
     12        * TestWebKitAPI/Tests/WTF/CrossThreadTask.cpp:
     13        (TestWebKitAPI::LifetimeLogger::LifetimeLogger):
     14        (TestWebKitAPI::LifetimeLogger::~LifetimeLogger):
     15        (TestWebKitAPI::LifetimeLogger::isolatedCopy):
     16        (TestWebKitAPI::LifetimeLogger::fullName):
     17        (TestWebKitAPI::testFunction):
     18        (TestWebKitAPI::TEST):
     19        (TestWebKitAPI::LifetimeLogger::log): Deleted.
     20        (TestWebKitAPI::LifetimeLogger::takeLogStr): Deleted.
     21
    1222016-06-09  Alex Christensen  <achristensen@webkit.org>
    223
  • trunk/Tools/TestWebKitAPI/Tests/WTF/CrossThreadTask.cpp

    r201872 r201928  
    2828#include <string>
    2929#include <wtf/CrossThreadTask.h>
     30#include <wtf/HashCountedSet.h>
     31#include <wtf/text/StringHash.h>
    3032
    3133namespace TestWebKitAPI {
     34
     35static size_t totalDestructorCalls;
     36static size_t totalIsolatedCopyCalls;
     37
     38static HashCountedSet<String> defaultConstructorSet;
     39static HashCountedSet<String> nameConstructorSet;
     40static HashCountedSet<String> copyConstructorSet;
     41static HashCountedSet<String> moveConstructorSet;
    3242
    3343struct LifetimeLogger {
    3444    LifetimeLogger()
    3545    {
    36         log() << "default_constructor(" << &name << "-" << copyGeneration << "-" << moveGeneration << ") ";
     46        defaultConstructorSet.add(fullName());
    3747    }
    3848
     
    4050        : name(*inputName)
    4151    {
    42         log() << "name_constructor(" << &name << "-" << copyGeneration << "-" << moveGeneration << ") ";
     52        nameConstructorSet.add(fullName());
    4353    }
    4454
     
    4858        , moveGeneration(other.moveGeneration)
    4959    {
    50         log() << "copy_constructor(" << &name << "-" << copyGeneration << "-" << moveGeneration << ") ";
     60        copyConstructorSet.add(fullName());
    5161    }
    5262
     
    5666        , moveGeneration(other.moveGeneration + 1)
    5767    {
    58         log() << "move_constructor(" << &name << "-" << copyGeneration << "-" << moveGeneration << ") ";
     68        moveConstructorSet.add(fullName());
    5969    }
    6070
    6171    ~LifetimeLogger()
    6272    {
    63         log() << "destructor(" << &name << "-" << copyGeneration << "-" << moveGeneration << ") ";
     73        ++totalDestructorCalls;
    6474    }
    6575
    6676    LifetimeLogger isolatedCopy() const
    6777    {
    68         log() << "isolatedCopy() ";
     78        ++totalIsolatedCopyCalls;
    6979        return LifetimeLogger(*this);
     80    }
     81
     82    String fullName()
     83    {
     84        return makeString(&name, "-", String::number(copyGeneration), "-", String::number(moveGeneration));
    7085    }
    7186
     
    7388    int copyGeneration { 0 };
    7489    int moveGeneration { 0 };
    75 
    76     static std::ostringstream& log()
    77     {
    78         static std::ostringstream log;
    79         return log;
    80     }
    81 
    82     static std::string takeLogStr()
    83     {
    84         std::string string = log().str();
    85         log().str("");
    86         return string;
    87     }
    8890};
    8991
    9092void testFunction(const LifetimeLogger&, const LifetimeLogger&, const LifetimeLogger&)
    9193{
    92     LifetimeLogger::log() << "testFunction called" << " ";
     94    // Do nothing - Just need to check the side effects of the arguments getting in here.
    9395}
    9496
     
    103105        task.performTask();
    104106    }
    105     ASSERT_STREQ("default_constructor(<default>-0-0) copy_constructor(<default>-1-0) name_constructor(logger-0-0) isolatedCopy() copy_constructor(<default>-1-0) isolatedCopy() copy_constructor(<default>-2-0) isolatedCopy() copy_constructor(logger-1-0) move_constructor(<default>-1-1) move_constructor(<default>-2-1) move_constructor(logger-1-1) destructor(logger-1-0) destructor(<default>-2-0) destructor(<default>-1-0) move_constructor(<default>-1-2) move_constructor(<default>-2-2) move_constructor(logger-1-2) destructor(logger-1-1) destructor(<default>-2-1) destructor(<default>-1-1) testFunction called destructor(logger-1-2) destructor(<default>-2-2) destructor(<default>-1-2) destructor(logger-0-0) destructor(<default>-1-0) destructor(<default>-0-0) ", LifetimeLogger::takeLogStr().c_str());
     107
     108    ASSERT_EQ(1u, defaultConstructorSet.size());
     109    ASSERT_EQ(1u, defaultConstructorSet.count("<default>-0-0"));
     110
     111    ASSERT_EQ(1u, nameConstructorSet.size());
     112    ASSERT_EQ(1u, nameConstructorSet.count("logger-0-0"));
     113
     114    ASSERT_EQ(3u, copyConstructorSet.size());
     115    ASSERT_EQ(1u, copyConstructorSet.count("logger-1-0"));
     116    ASSERT_EQ(2u, copyConstructorSet.count("<default>-1-0"));
     117    ASSERT_EQ(1u, copyConstructorSet.count("<default>-2-0"));
     118
     119    ASSERT_EQ(6u, moveConstructorSet.size());
     120    ASSERT_EQ(1u, moveConstructorSet.count("logger-1-1"));
     121    ASSERT_EQ(1u, moveConstructorSet.count("logger-1-2"));
     122    ASSERT_EQ(1u, moveConstructorSet.count("<default>-2-1"));
     123    ASSERT_EQ(1u, moveConstructorSet.count("<default>-2-2"));
     124    ASSERT_EQ(1u, moveConstructorSet.count("<default>-1-1"));
     125    ASSERT_EQ(1u, moveConstructorSet.count("<default>-1-2"));
     126
     127    ASSERT_EQ(12u, totalDestructorCalls);
     128    ASSERT_EQ(3u, totalIsolatedCopyCalls);
     129
    106130}
    107131   
Note: See TracChangeset for help on using the changeset viewer.