1484543d1Sopenharmony_ci/*
2484543d1Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
3484543d1Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4484543d1Sopenharmony_ci * you may not use this file except in compliance with the License.
5484543d1Sopenharmony_ci * You may obtain a copy of the License at
6484543d1Sopenharmony_ci *
7484543d1Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8484543d1Sopenharmony_ci *
9484543d1Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10484543d1Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11484543d1Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12484543d1Sopenharmony_ci * See the License for the specific language governing permissions and
13484543d1Sopenharmony_ci * limitations under the License.
14484543d1Sopenharmony_ci */
15484543d1Sopenharmony_ci#include <gtest/gtest.h>
16484543d1Sopenharmony_ci#include "ffrt_inner.h"
17484543d1Sopenharmony_ci#include "c/executor_task.h"
18484543d1Sopenharmony_ci#include "tm/scpu_task.h"
19484543d1Sopenharmony_ci#include "dfx/log/ffrt_log_api.h"
20484543d1Sopenharmony_ci#include <cinttypes>
21484543d1Sopenharmony_ci#include "../common.h"
22484543d1Sopenharmony_ci
23484543d1Sopenharmony_ciusing namespace std;
24484543d1Sopenharmony_ciusing namespace ffrt;
25484543d1Sopenharmony_ciusing namespace testing;
26484543d1Sopenharmony_ci#ifdef HWTEST_TESTING_EXT_ENABLE
27484543d1Sopenharmony_ciusing namespace testing::ext;
28484543d1Sopenharmony_ci#endif
29484543d1Sopenharmony_ci
30484543d1Sopenharmony_ciclass InheritTest : public testing::Test {
31484543d1Sopenharmony_ciprotected:
32484543d1Sopenharmony_ci    static void SetUpTestCase()
33484543d1Sopenharmony_ci    {
34484543d1Sopenharmony_ci    }
35484543d1Sopenharmony_ci
36484543d1Sopenharmony_ci    static void TearDownTestCase()
37484543d1Sopenharmony_ci    {
38484543d1Sopenharmony_ci    }
39484543d1Sopenharmony_ci
40484543d1Sopenharmony_ci    virtual void SetUp()
41484543d1Sopenharmony_ci    {
42484543d1Sopenharmony_ci    }
43484543d1Sopenharmony_ci
44484543d1Sopenharmony_ci    virtual void TearDown()
45484543d1Sopenharmony_ci    {
46484543d1Sopenharmony_ci    }
47484543d1Sopenharmony_ci};
48484543d1Sopenharmony_ci
49484543d1Sopenharmony_ciHWTEST_F(InheritTest, executorToCPUEUTask, TestSize.Level1)
50484543d1Sopenharmony_ci{
51484543d1Sopenharmony_ci    ffrt_executor_task_t w;
52484543d1Sopenharmony_ci    w.type = 1;
53484543d1Sopenharmony_ci    auto* cputask = reinterpret_cast<SCPUEUTask*>(&w);
54484543d1Sopenharmony_ci    printf("w.addr:%" PRIx64 "\n", reinterpret_cast<uint64_t>(&w));
55484543d1Sopenharmony_ci    printf("w.type Addr%" PRIx64 "\n", reinterpret_cast<uint64_t>(&(w.type)));
56484543d1Sopenharmony_ci
57484543d1Sopenharmony_ci    printf("cputask base Addr %" PRIx64 "\n", reinterpret_cast<uint64_t>(cputask));
58484543d1Sopenharmony_ci    printf("cputask.type TaskBase Addr%" PRIx64 "\n", reinterpret_cast<uint64_t>(&(cputask->type)));
59484543d1Sopenharmony_ci    printf("cputask.rc Taskdeleter Addr %" PRIx64 "\n", reinterpret_cast<uint64_t>(&cputask->rc));
60484543d1Sopenharmony_ci    printf("cputask.wue Addr %" PRIx64 "\n", reinterpret_cast<uint64_t>(&cputask->wue));
61484543d1Sopenharmony_ci
62484543d1Sopenharmony_ci    EXPECT_EQ(w.type, 1);
63484543d1Sopenharmony_ci    EXPECT_EQ(cputask->type, 1);
64484543d1Sopenharmony_ci    EXPECT_EQ(reinterpret_cast<uint64_t>(&(w.type)), reinterpret_cast<uint64_t>(&(cputask->type)));
65484543d1Sopenharmony_ci}