1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#include <gtest/gtest.h>
16#include "ffrt_inner.h"
17#include "c/executor_task.h"
18#include "tm/scpu_task.h"
19#include "dfx/log/ffrt_log_api.h"
20#include <cinttypes>
21#include "../common.h"
22
23using namespace std;
24using namespace ffrt;
25using namespace testing;
26#ifdef HWTEST_TESTING_EXT_ENABLE
27using namespace testing::ext;
28#endif
29
30class InheritTest : public testing::Test {
31protected:
32    static void SetUpTestCase()
33    {
34    }
35
36    static void TearDownTestCase()
37    {
38    }
39
40    virtual void SetUp()
41    {
42    }
43
44    virtual void TearDown()
45    {
46    }
47};
48
49HWTEST_F(InheritTest, executorToCPUEUTask, TestSize.Level1)
50{
51    ffrt_executor_task_t w;
52    w.type = 1;
53    auto* cputask = reinterpret_cast<SCPUEUTask*>(&w);
54    printf("w.addr:%" PRIx64 "\n", reinterpret_cast<uint64_t>(&w));
55    printf("w.type Addr%" PRIx64 "\n", reinterpret_cast<uint64_t>(&(w.type)));
56
57    printf("cputask base Addr %" PRIx64 "\n", reinterpret_cast<uint64_t>(cputask));
58    printf("cputask.type TaskBase Addr%" PRIx64 "\n", reinterpret_cast<uint64_t>(&(cputask->type)));
59    printf("cputask.rc Taskdeleter Addr %" PRIx64 "\n", reinterpret_cast<uint64_t>(&cputask->rc));
60    printf("cputask.wue Addr %" PRIx64 "\n", reinterpret_cast<uint64_t>(&cputask->wue));
61
62    EXPECT_EQ(w.type, 1);
63    EXPECT_EQ(cputask->type, 1);
64    EXPECT_EQ(reinterpret_cast<uint64_t>(&(w.type)), reinterpret_cast<uint64_t>(&(cputask->type)));
65}