[webkit-changes] [WebKit/WebKit] 66ffe5: [WK2] Add test cases testing move occurrences duri...

Žan Doberšek noreply at github.com
Thu Dec 8 06:19:54 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 66ffe5bc6f05344ffb99942f90de5c275049c8cf
      https://github.com/WebKit/WebKit/commit/66ffe5bc6f05344ffb99942f90de5c275049c8cf
  Author: Žan Doberšek <zdobersek at igalia.com>
  Date:   2022-12-08 (Thu, 08 Dec 2022)

  Changed paths:
    M Tools/TestWebKitAPI/Tests/IPC/ArgumentCoderTests.cpp

  Log Message:
  -----------
  [WK2] Add test cases testing move occurrences during IPC decoding
https://bugs.webkit.org/show_bug.cgi?id=248887

Reviewed by Kimmo Kinnunen.

Add test cases that check the amount of moves an object of a given type
goes through during IPC decoding.

The test cases use a move-only DecodingMoveCounter struct that increases
the move counter whenever constructed through a move operation. This is
used to assess the amount of moves a given object went through during
the IPC decoding process.

A fixture class is provided, internally establishing an IPC::Encoder
object into which the test case can encode the desired object. The
encoder's buffer is then used for the IPC::Decoder from which decoding
is then done. In each test, a certain amount of moves is expected and
appropriately validated.

The actual amount of moves depends on the way the decoding is done and
on any container or wrapping object used.

The test cases show that one move can be immediately avoided if the
IPC::Decoder::decode<T>() method is used instead of constructing an
empty std::optional<T> and using the stream extraction operator with
that optional object as the destination. Avoiding and replacing the use
of the stream extraction operator should be considered.

Testing the decoding of containers and wrapper objects also shows an
abundance of moves occurring for the wrapped object. I think probably
in all cases this could be reduced down to a single move of a
DecodingMoveCounter object.

* Tools/TestWebKitAPI/Tests/IPC/ArgumentCoderTests.cpp:
(TestWebKitAPI::DecodingMoveCounter::DecodingMoveCounter):
(TestWebKitAPI::DecodingMoveCounter::operator=):
(TestWebKitAPI::DecodingMoveCounter::encode):
(TestWebKitAPI::DecodingMoveCounter::decode):
(TestWebKitAPI::DecodingMoveCounterTest::name):
(TestWebKitAPI::ArgumentCoderDecodingMoveCounterTest::encoder const):
(TestWebKitAPI::ArgumentCoderDecodingMoveCounterTest::createDecoder const):
(TestWebKitAPI::TEST_F):

Canonical link: https://commits.webkit.org/257562@main




More information about the webkit-changes mailing list