-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetect_bloated_strace.sh
46 lines (32 loc) · 1.19 KB
/
detect_bloated_strace.sh
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
jsonlist=$(jq -r '.projects' "repos.json")
for row in $(echo "${jsonlist}" | jq -r '.[] | @base64')
do
_jq()
{
echo ${row} | base64 --decode | jq -r ${1}
}
repoUrl=$(_jq '.gitURL')
projectName=$(_jq '.folder')
folderPath="Playground/"$(_jq '.folder')
commit=$(_jq '.commit')
unitTest=$(_jq '.unitTest')
# echo $repoUrl
echo $folderPath
git clone $repoUrl $folderPath
cd $folderPath
git checkout $commit
# cp "../../LockFiles/${projectName}/package-lock.json" ./
npm install
cd ../..
# extract the list of runtime dependencies
python3 identify_runtime_from_lock.py $projectName "Playground"
echo "Start running test..."
cd $folderPath
# run test and trace open/openat .js/.json files at the OS level
strace -f -e trace=open,openat -o npm_test_trace.txt npm run $unitTest
# grep
grep -E "open\(|openat\(" npm_test_trace.txt | awk -F, '{print $2}' | grep "/${projectName}" | grep -E ".js\"$|.json\"$" | sort | uniq > "npm_test_opened_files.txt"
cd ../..
echo "Start discovering bloated files and dependencies..."
python3 extract_bloated_candidates.py $projectName "Playground"
done