• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <cinttypes>
17 #include "ffrt_inner.h"
18 #include "c/executor_task.h"
19 #include "tm/scpu_task.h"
20 #include "dfx/log/ffrt_log_api.h"
21 #include "../common.h"
22 
23 using namespace std;
24 using namespace ffrt;
25 using namespace testing;
26 #ifdef HWTEST_TESTING_EXT_ENABLE
27 using namespace testing::ext;
28 #endif
29 
30 class InheritTest : public testing::Test {
31 protected:
SetUpTestCase()32     static void SetUpTestCase()
33     {
34     }
35 
TearDownTestCase()36     static void TearDownTestCase()
37     {
38     }
39 
SetUp()40     void SetUp() override
41     {
42     }
43 
TearDown()44     void TearDown() override
45     {
46     }
47 };
48 
49 HWTEST_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 }