Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 448e9e86 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "rpc_binder: weigh sending a message to a TA more heavily in `trusty_tipc_fuzzer`" into main

parents d217d8dc 2cc72c0e
Loading
Loading
Loading
Loading
+40 −41
Original line number Diff line number Diff line
@@ -97,34 +97,29 @@ void testOneInput(FuzzedDataProvider& provider) {
        static_assert(MAX_CONNECTIONS >= 1);

        // Either
        // 1. Add a new TA and connect.
        // 2. Remove a TA.
        // 3. Send a random message to a random TA.
        const std::function<void()> options[] = {
                // Add a new TA and connect.
                [&]() {
        // 1. (20%) Add a new TA and connect.
        // 2. (20%) Remove a TA.
        // 3. (60%) Send a random message to a random TA.
        auto add_ta = [&]() {
            if (trustyApps.size() >= MAX_CONNECTIONS) {
                return;
            }
            auto& ta = trustyApps.emplace_back(TIPC_DEV, TRUSTY_APP_PORT);
            abortResult(ta.Connect());
                },
                // Remove a TA.
                [&]() {
        };
        auto remove_ta = [&]() {
            if (trustyApps.empty()) {
                return;
            }
            trustyApps.pop_back();
                },
                // Send a random message to a random TA.
                [&]() {
        };
        auto send_message = [&]() {
            if (trustyApps.empty()) {
                return;
            }

            // Choose a random TA.
                    const auto i =
                            provider.ConsumeIntegralInRange<size_t>(0, trustyApps.size() - 1);
            const auto i = provider.ConsumeIntegralInRange<size_t>(0, trustyApps.size() - 1);
            std::swap(trustyApps[i], trustyApps.back());
            auto& ta = trustyApps.back();

@@ -138,7 +133,11 @@ void testOneInput(FuzzedDataProvider& provider) {
            // Reconnect to ensure that the service is still up.
            ta.Disconnect();
            abortResult(ta.Connect());
                },
        };
        const std::function<void()> options[] = {
                add_ta,                                    // 1x: 20%
                remove_ta,                                 // 1x: 20%
                send_message, send_message, send_message,  // 3x: 60%
        };

        provider.PickValueInArray(options)();