Merge "enhance test cases description and provide more info(in progress)"
[yardstick.git] / yardstick / benchmark / scenarios / parser / parser.sh
1 #!/bin/bash
2
3 ##############################################################################
4 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
11
12 set -e
13
14 # Commandline arguments
15 yangfile=$1
16 base_dir=$(dirname $yangfile)
17 shift
18 toscafile=$1
19 OUTPUT_FILE=/tmp/parser-out.log
20
21 # run parser test
22 run_parser()
23 {
24     cd /tmp/parser/yang2tosca
25     python tosca_translator.py  --filename $yangfile> $OUTPUT_FILE
26 }
27
28 # write the result to stdout in json format
29 check_result()
30 {
31
32     if (diff -q $toscafile ${yangfile%'.yaml'}"_tosca.yaml" >> $OUTPUT_FILE);
33         then
34         exit 0
35     else
36         exit 1
37     fi
38
39 }
40
41 # main entry
42 main()
43 {
44     # run the test
45     run_parser
46
47     # output result
48     check_result
49 }
50
51 main