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

Commit 4a4181c3 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 4779114 from 5acc0b1f to pi-release

Change-Id: I5bc95aee3c7ec5faae4805d83223d43c27ff4341
parents 5753b07c 5acc0b1f
Loading
Loading
Loading
Loading
+17 −23
Original line number Original line Diff line number Diff line
@@ -26,7 +26,6 @@
#include <android/hardware/tetheroffload/control/1.0/types.h>
#include <android/hardware/tetheroffload/control/1.0/types.h>
#include <linux/netfilter/nfnetlink.h>
#include <linux/netfilter/nfnetlink.h>
#include <linux/netlink.h>
#include <linux/netlink.h>
#include <log/log.h>
#include <net/if.h>
#include <net/if.h>
#include <sys/socket.h>
#include <sys/socket.h>
#include <unistd.h>
#include <unistd.h>
@@ -59,18 +58,14 @@ constexpr const char* TEST_IFACE = "rmnet_data0";
// We use #defines here so as to get local lamba captures and error message line numbers
// We use #defines here so as to get local lamba captures and error message line numbers
#define ASSERT_TRUE_CALLBACK                                                    \
#define ASSERT_TRUE_CALLBACK                                                    \
    [&](bool success, std::string errMsg) {                                     \
    [&](bool success, std::string errMsg) {                                     \
        if (!success) {                                 \
        std::string msg = StringPrintf("unexpected error: %s", errMsg.c_str()); \
            ALOGI("Error message: %s", errMsg.c_str()); \
        ASSERT_TRUE(success) << msg;                                            \
        }                                               \
        ASSERT_TRUE(success);                           \
    }
    }


#define ASSERT_FALSE_CALLBACK                                                 \
#define ASSERT_FALSE_CALLBACK                                                 \
    [&](bool success, std::string errMsg) {                                   \
    [&](bool success, std::string errMsg) {                                   \
        if (!success) {                                 \
        std::string msg = StringPrintf("expected error: %s", errMsg.c_str()); \
            ALOGI("Error message: %s", errMsg.c_str()); \
        ASSERT_FALSE(success) << msg;                                         \
        }                                               \
        ASSERT_FALSE(success);                          \
    }
    }


#define ASSERT_ZERO_BYTES_CALLBACK            \
#define ASSERT_ZERO_BYTES_CALLBACK            \
@@ -188,10 +183,9 @@ class OffloadControlHidlTestBase : public testing::VtsHalHidlTargetTestBase {


    void initOffload(const bool expected_result) {
    void initOffload(const bool expected_result) {
        auto init_cb = [&](bool success, std::string errMsg) {
        auto init_cb = [&](bool success, std::string errMsg) {
            if (!success) {
            std::string msg = StringPrintf("Unexpectedly %s to init offload: %s",
                ALOGI("Error message: %s", errMsg.c_str());
                                           success ? "succeeded" : "failed", errMsg.c_str());
            }
            ASSERT_EQ(expected_result, success) << msg;
            ASSERT_EQ(expected_result, success);
        };
        };
        const Return<void> ret = control->initOffload(control_cb, init_cb);
        const Return<void> ret = control->initOffload(control_cb, init_cb);
        ASSERT_TRUE(ret.isOk());
        ASSERT_TRUE(ret.isOk());
@@ -204,15 +198,12 @@ class OffloadControlHidlTestBase : public testing::VtsHalHidlTargetTestBase {


    void stopOffload(const ExpectBoolean value) {
    void stopOffload(const ExpectBoolean value) {
        auto cb = [&](bool success, const hidl_string& errMsg) {
        auto cb = [&](bool success, const hidl_string& errMsg) {
            if (!success) {
                ALOGI("Error message: %s", errMsg.c_str());
            }
            switch (value) {
            switch (value) {
                case ExpectBoolean::False:
                case ExpectBoolean::False:
                    ASSERT_EQ(false, success);
                    ASSERT_EQ(false, success) << "Unexpectedly able to stop offload: " << errMsg;
                    break;
                    break;
                case ExpectBoolean::True:
                case ExpectBoolean::True:
                    ASSERT_EQ(true, success);
                    ASSERT_EQ(true, success) << "Unexpectedly failed to stop offload: " << errMsg;
                    break;
                    break;
                case ExpectBoolean::Ignored:
                case ExpectBoolean::Ignored:
                    break;
                    break;
@@ -289,8 +280,11 @@ TEST_F(OffloadControlHidlTestBase, AdditionalStopsWithInitReturnFalse) {
    if (!interfaceIsUp(TEST_IFACE)) {
    if (!interfaceIsUp(TEST_IFACE)) {
        return;
        return;
    }
    }
    stopOffload(ExpectBoolean::True);  // balance out initOffload(true)
    SCOPED_TRACE("Expecting stopOffload to succeed");
    stopOffload(ExpectBoolean::Ignored);  // balance out initOffload(true)
    SCOPED_TRACE("Expecting stopOffload to fail the first time");
    stopOffload(ExpectBoolean::False);
    stopOffload(ExpectBoolean::False);
    SCOPED_TRACE("Expecting stopOffload to fail the second time");
    stopOffload(ExpectBoolean::False);
    stopOffload(ExpectBoolean::False);
}
}