• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
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: generate_config.sh
15#
16# Description: generate config for linux test project
17#
18# Authors:     Wu Fan
19#
20# History:     August 4 2022 - generate config
21#
22################################################################################
23set -e
24IFS=$'\n'
25input_file=$2/macrolists
26change_file=$3/ltp/include/config.h
27
28function chang_config()
29{
30    while read line; do
31        if [[ "${line}" == *"#"* ]]; then
32            continue
33        else
34            macro=$(echo $line | awk -F "'" '{print $2}')
35            flag=$(echo $line | awk -F "'" '{print $4}')
36	    set +e
37            if [ "${flag}" == "true" ]; then
38                lines=$(sed -n "/${macro}/=" $change_file)
39                if [[ "${lines}" > 0 ]]; then
40                    sed -i "/${macro}/c\#define ${macro} 1" $change_file
41                else
42                    echo "#define ${macro} 1" >> $change_file
43                fi
44            else
45                sed -i "/${macro}/c\/\* \#undef ${macro} \*\/" $change_file
46            fi
47            set -e
48        fi
49    done < $input_file
50    echo "typedef unsigned int __u32;" >> $change_file
51    echo "typedef signed int __s32;" >> $change_file
52}
53
54mkdir -p $(pwd)/tests/ltp_testcases/ltp
55cp -r $(pwd)/../../third_party/ltp $(pwd)/tests/ltp_testcases
56cd $(pwd)/tests/ltp_testcases/ltp
57make autotools
58./configure --without-numa
59add_notation=./include/tst_clone.h
60sed -i "/^\#define clone/c\/\/ \#define clone(...) (use_the_ltp_clone_functions__do_not_use_clone)" $add_notation
61chang_config
62