• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2################################################################################
3#
4# Copyright (C) 2022 Huawei Device Co., Ltd.
5# SPDX-License-Identifier: GPL-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS,
9# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10# See the License for the specific language governing permissions and
11# limitations under the License.
12#
13################################################################################
14# File: enhancedswap_t_init.sh
15#
16# Description: enhancedswap_t testsuite init script
17#
18# Authors:     Ma Feng - mafeng.ma@huawei.com
19#
20# History:     Mar 24 2022 - init scripts
21#
22################################################################################
23
24pre_condition()
25{
26
27}
28
29uninit_platform()
30{
31    losetup -d /dev/block/loop7
32    echo ${hyperhold_device} > /proc/sys/kernel/hyperhold/device
33    echo ${hyperhold_enable} > /proc/sys/kernel/hyperhold/enable
34    echo ${zram0_group} > /sys/block/zram0/group
35    echo ${zram0_disksize} > /sys/block/zram0/disksize
36    rm -rf hpdisk
37    swapoff /dev/block/zram0
38    echo 1 > /sys/block/zram0/reset
39}
40
41hp_init()
42{
43    dd if=/dev/random of=hpdisk bs=4096 count=131072
44    losetup /dev/block/loop7 hpdisk
45    hyperhold_device=$(cat /proc/sys/kernel/hyperhold/device)
46    echo /dev/block/loop7 > /proc/sys/kernel/hyperhold/device
47}
48
49hp_enable()
50{
51    hyperhold_enable=$(cat /proc/sys/kernel/hyperhold/enable)
52    echo enable > /proc/sys/kernel/hyperhold/enable
53}
54
55zram_init()
56{
57    zram0_group=$(cat /sys/block/zram0/group)
58    zram0_disksize=$(cat /sys/block/zram0/disksize)
59    echo readwrite > /sys/block/zram0/group
60    echo 512M > /sys/block/zram0/disksize
61}
62
63zram_enable()
64{
65    mkswap /dev/block/zram0
66    swapon /dev/block/zram0
67    aa start -b com.ohos.settings -a com.ohos.settings.MainAbility
68    aa start -b ohos.samples.airquality -a ohos.samples.airquality.default
69    aa start -b ohos.samples.ecg -a ohos.samples.ecg.MainAbility
70    aa start -b ohos.samples.flashlight -a ohos.samples.flashlight.default
71    aa start -b ohos.samples.clock -a ohos.samples.clock.default
72    aa start -b com.ohos.camera -a com.ohos.camera.MainAbility
73    aa start -b com.ohos.permissionmanager -a com.ohos.permissionmanager.MainAbility
74    aa start -b ohos.sample.shopping -a com.example.entry.MainAbility
75    aa start -b ohos.samples.distributedcalc -a ohos.samples.distributedcalc.MainAbility
76
77}
78
79echo "***************************ESWAP INIT START***************************"
80free -m
81uninit_platform
82pre_condition
83hp_init
84hp_enable
85zram_init
86zram_enable
87echo "***************************ESWAP INIT END***************************"