summaryrefslogtreecommitdiffstats
path: root/src/build/hwpf/prcd_compile_test
blob: 69c6969a34f46b40cc6be9fb7657bcaab06a6f25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/bin/bash
#  IBM_PROLOG_BEGIN_TAG
#  This is an automatically generated prolog.
#
#  $Source: src/build/hwpf/prcd_compile_test $
#
#  IBM CONFIDENTIAL
#
#  COPYRIGHT International Business Machines Corp. 2011
#
#  p1
#
#  Object Code Only (OCO) source materials
#  Licensed Internal Code Source Materials
#  IBM HostBoot Licensed Internal Code
#
#  The source code for this program is not published or other-
#  wise divested of its trade secrets, irrespective of what has
#  been deposited with the U.S. Copyright Office.
#
#  Origin: 30
#
#  IBM_PROLOG_END

#Note that this test case assumes 3 files present in the PWD (along with prcd_compile.tcl)
# - fapiTestHwp.C fapiTestHwp.H proc_cen_framelock.C
# and 1 file in a subdirectory
#  dmi_training/proc_cen_framelock/proc_cen_framelock.H

BUILD="b0218a_2012_Sprint9"

###############################################################
# Validate return code, exit on failure
###############################################################
function check_good_rc {

    if [ $1 -eq 0 ]; then
        echo SUCCESS
        echo
    else
        echo FAIL: Bad RC Returned:$1; exit -1
    fi
}

###############################################################
# Validate return code and that binary was generated, exit on failure
###############################################################
function check_good_rc_and_bin {

    if [ -f $2/hbicore.bin ] && [ -f $2/hbicore_extended.bin ] && [ -f $2/hbotStringFile ]; then
        check_good_rc $1        
        rm -f $2/hbicore*    
        rm -f $2/*.bin
        rm -f $2/hbotStringFile
    else
        echo FAIL: Missing File; exit -1
    fi
}

###############################################################
# Validate return code is non-zero, exit on failure
###############################################################
function check_bad_rc {

    if [ $1 -ne 0 ]; then
        echo SUCCESS
        echo
    else
        echo FAIL; exit -1
    fi
}

###############################################################
# Main
###############################################################

# Check if the needed files exist, if not try and copy them in
if [ ! -f "./fapiTestHwp.H" ]; then
    cp ../../include/usr/hwpf/hwp/fapiTestHwp.H ./
    check_good_rc $?
fi

if [ ! -f "./fapiTestHwp.C" ]; then
    cp ../../usr/hwpf/hwp/fapiTestHwp.C ./
    check_good_rc $?
fi

if [ ! -f "./sample.initfile" ]; then
    cp ../../usr/hwpf/hwp/initfiles/sample.initfile ./
    check_good_rc $?
fi

if [ ! -f "./proc_cen_framelock.C" ]; then
    cp ../../usr/hwpf/hwp/dmi_training/proc_cen_framelock/proc_cen_framelock.H ./
    check_good_rc $?
fi

if [ ! -f "./dmi_training/proc_cen_framelock/proc_cen_framelock.H" ]; then
    mkdir -p dmi_training/proc_cen_framelock
    cp ../../usr/hwpf/hwp/dmi_training/proc_cen_framelock/proc_cen_framelock.H ./dmi_training/proc_cen_framelock
    check_good_rc $?
fi

echo 

echo "TEST - Good Path - Multi Process"
{ ./prcd_compile.tcl -d $BUILD -o out1 ./fapiTestHwp.H; check_good_rc_and_bin $? ./out1; } &
sleep 2
{ ./prcd_compile.tcl -d $BUILD -o out2 ./fapiTestHwp.C; check_good_rc_and_bin $? ./out2; } &
sleep 2
{ ./prcd_compile.tcl -d $BUILD -o out3 ./fapiTestHwp.H ./fapiTestHwp.C; check_good_rc_and_bin $? ./out3; } &
wait

echo
echo "TEST - Good Path - 1 C File"
./prcd_compile.tcl -d $BUILD ./fapiTestHwp.C
check_good_rc_and_bin $? ./

echo
echo "TEST - Good Path - 1 H File with -o Param"
./prcd_compile.tcl -d $BUILD -o ./ ./fapiTestHwp.H
check_good_rc_and_bin $? ./

echo
echo "TEST - Good Path - 2 Files"
./prcd_compile.tcl -d $BUILD ./proc_cen_framelock.C ./fapiTestHwp.C
check_good_rc_and_bin $? ./

echo
echo "TEST - Good Path - buried File"
./prcd_compile.tcl -d $BUILD ./dmi_training/proc_cen_framelock/proc_cen_framelock.H
check_good_rc_and_bin $? ./

echo
echo "TEST - Good Path - No Files"
./prcd_compile.tcl -d $BUILD
check_good_rc_and_bin $? ./

echo
echo "TEST - Good Path - Initfile"
./prcd_compile.tcl -o ./output/ sample.initfile
check_good_rc_and_bin $? ./output/

echo
echo "TEST - Good Path - All Files"
./prcd_compile.tcl -o ./output/ sample.initfile fapiTestHwp.H ./fapiTestHwp.C
check_good_rc_and_bin $? ./output/

echo
echo "TEST - New working HWP"
cat >> mss_compile_test.C << EOF
#include <fapi.H>
#include <mss_compile_test.H>
fapi::ReturnCode mss_compile_test(std::vector<fapi::Target> & i_targets_memb)
{ fapi::ReturnCode l_rc; return l_rc; }   
EOF
cat >> mss_compile_test.H << EOF
#ifndef MSS_COMPILE_TESTHWPB_H_
#define MSS_COMPILE_TESTHWPB_H_
#include <fapi.H>
typedef fapi::ReturnCode (*mss_comile_test_FP_t)(std::vector<fapi::Target> &);
extern "C" { fapi::ReturnCode mss_comile_test(std::vector<fapi::Target> & l_targets_memb); }
#endif
EOF
./prcd_compile.tcl -n mss_compile_test.C mss_compile_test.H
check_good_rc $?

echo
echo "TEST - New working HWP - missing .H file"
./prcd_compile.tcl -n mss_compile_test.C
check_bad_rc $?

echo
echo "TEST - Good Path - Compile Failure" 
echo COMPILE_FAIL >> fapiTestHwp.H
./prcd_compile.tcl -d $BUILD fapiTestHwp.H fapiTestHwp.C
check_bad_rc $?
OpenPOWER on IntegriCloud