SWEN90006

The University of Melbourne
SWEN90006: Software Testing and Reliability
Assignment 1
Second Semester, 2018

Name:Xujia Zhu
Stu ID:951633

Task 1

First, we consider the input domain of this program:
(1) This list of strings must have instruction “RET”.
(2)The instruction in this list of strings must be one of “ADD,SUB,MUL,DIV,RET,MOV,LDR,STR,JMP,JZ”these 10 instructions or begin with “;”.
(3)Each register mentioned in the list of strings like Rx,must satisfy the condition: 0<=x<=31.
(4)The value of val in the instruction MOV must satisfy the condition: -65535<=v<=65535.
(5)The value of val in the instruction LDR and STR must satisfy the condition: 0<=b+v<=65535.
(6)The value of val in the instruction JMP and JZ must satisfy the condition: 0<=pc+v<=N-1.

Then, we examine the requirements and have the equivalence classes.
(1)Applying to guideline 2, we have two equivalence classes, list of strings which have the instruction RET, and which not. The valid class is the list of strings which have the instruction RET. The invalid class is the list of strings which don’t have the instruction RET.
(2)Applying to guideline 2, all instructions in the list of strings can be divided into 2 kinds: instructions starting with “;” and not. The valid class is instructions starting with “;”. We need to further divide the instructions not beginning with “;”.
(3)Continued from the preceding paragraph, applying to guideline 2, instructions not beginning with “;” can be divided into 2 kinds: instructions begin with one of “ADD,SUB,MUL,DIV,RET,MOV,LDR,STR,JMP,JZ” these 10 instructions, and instructions not begin with these 10 situations. The invalid class is instructions not begin with these 10 situations. And we need to divide the valid class further.
Then we are going to talk about instructions begin with these 10 situations:
(1)In these 10 kinds of instructions, which begin with “ADD,SUB,DIV,MUL,RET”, because the assumptions say that there are no syntax errors, so we only consider the value problem of the x in Rx.Applying to guideline 1, there are three equivalence classes, one of x in Rx <0, all of x in Rx are between 0 and 31, one of x in Rx >31.The valid class is all of x in Rx in these instructions are between 0 and 31, the invalid classes are one of x in Rx in these instructions < 0 and one of x in Rx in these instructions > 31.
(2)In these 10 kinds of instructions, which begin with “MOV”, if x in Rx is between 0 and 31,we can have another three equivalence classes applying to guideline 1: val<-65535, -65535<= val <=65535, val>65535. The valid classes are val in these instructions between -65535 and 65535. The invalid classes are val in these instructions which are < -65535 and > 65535.
(3)In these 10 kinds of instructions, which begin with “STR, LDR”, if x in Rx is between 0 and 31,we can have another three equivalence classes applying to guideline1: b+val<0, 0<=b+val <=65535, b+val>65535. The valid classes are b+val in these instructions between 0 and 65535. The invalid classes are b+val in these instructions which are <0 and >65535.
(4)In these 10 kinds of instructions, which begin with “STR, LDR”, if x in Rx is between 0 and 31,we can have another three equivalence classes applying to guideline1: pc+val<0, 0<=pc+val<=N-1,pc+val>N-1. The valid classes are pc+val in these instructions between 0 and N-1.The invalid classes are pc+val in these instructions which are <0 and >N-1.
The resulting test template tree is above.

Task 3
Using boundary-value analysis, we can select test cases by each side as on point and off point.
For x in Rx, we have
x = 0 (on point)
x = 31 (on point)
x = -1 (off point)
x = 31 (off point)
For val in instruction “MOV”, we have
val = -65535 (on point)
val = 65535 (on point)
val = -65536 (off point)
val = 65536 (off point)
For val in instruction LDR and STR, we have
b+v = 0 (on point)
b+v = 65535 (on point)
b+v = -1 (off point)
b+v = 65536 (off point)
For val in instruction JMP and JZ, we have
pc+val = 0 (on point)
pc+val = N-1 (on point)
pc+val = -1 (off point)
pc+val = N (off point)
The resulting tests are:
EC1 ;R1 hold N
MOV R1 1
RET R1 on point begin with “;”
EC2 MOV R1 1
MOV R2 2
ADD R-1 R1 R2
RET R-1 off point for one of a,b,c<0
EC3 MOV R1 1
MOV R2 2
ADD R0 R1 R2
RET R0 on point for one of a, b,c<0
MOV R1 1
MOV R2 2
ADD R31 R1 R2
RET R31 on point for one of a,b,c>31
EC4 MOV R1 1
MOV R2 2
ADD R32 R1 R2
RET R32 off point for one of a,b,c>31
EC5 MOV R-1 1
MOV R2 2
ADD R3 R-1 R2
RET R3 off point for a<0
EC6 MOV R0 -65536
MOV R1 2
ADD R3 R0 R1
RET R3 off point for val<-65535
EC7 MOV R0 -65535
MOV R1 2
ADD R3 R0 R1
RET R3 on pint for val<-65535
MOV R0 65535
MOV R1 2
ADD R3 R0 R1
RET R3 on point for val>65535
EC8 MOV R0 65536
MOV R1 2
ADD R3 R0 R1
RET R3 off point for val>65535
EC9 MOV R32 1
MOV R1 2
ADD R3 R32 R1
RET R3 off point for a>31
EC10 MOV R1 1
LDR R-1 R1 1
RET R-1 off point for a<0
EC11 MOV R0 1
LDR R1 R0 -1
RET R1 off point for b+v<0
EC12 MOV R0 1
LDR R1 R0 0
RET R1 on point for b+v<0
MOV R0 1
LDR R1 R0 65535
RET R1 on point for b+v>65535
EC13 MOV R1 1
LDR R2 R1 65535
RET R2 on point for b+v>65535
EC14 MOV R0 1
LDR R32 R0 1
RET R32 off point for a>31
EC15 MOV R-1 0
MOV R2 2
MOV R3 1
JZ R-1 2
SUB R0 R2 R3
ADD R4 R2 R3
RET R4 off point for a<0
EC16 MOV R1 0
MOV R2 2
MOV R3 1
JZ R1 -5
SUB R0 R2 R3
ADD R4 R2 R3
RET R4 off point for pc+val<0
EC17 MOV R1 0
MOV R2 2
MOV R3 1
JZ R1 -4
SUB R0 R2 R3
ADD R4 R2 R3
RET R4 on point for pc+val<0
MOV R1 0
MOV R2 2
MOV R3 1
JZ R1 2
SUB R0 R2 R3
ADD R4 R2 R3
RET R4 on point for pc+val>N-1
EC18 MOV R1 0
MOV R2 2
MOV R3 1
JZ R1 3
SUB R0 R2 R3
ADD R4 R2 R3
RET R4 off point for pc +val>N-1
EC19 MOV R32 0
MOV R2 2
MOV R3 1
JZ R32 2
SUB R0 R2 R3
ADD R4 R2 R3
RET R4 off point for a>31
EC20 ERC R1 R2
YGT R3 R1 R2
RET R3 off point for not begin with one of 10 instructions
EC21 MOV R1 1
MOV R2 2 off point for not contain RET instruction

Note that some equivalence classes have more than one test because there are multiple boundaries.

Task 5
Because we need to use control flow.And we are using multiple-condition coverage.So we need to combine all of conditions.
There are
10 if statements containing two conditions
3 if statements containing a single condition
This gives a total of 102+3=23 conditions,and
10
22+32=46 condition permutations
For testing , list the conditions:
condition Branch code permutations
C1||C2 if (pc < 0 || pc >= progLength) {00,01,10,11}
C3 if (inst.equals("")) {0,1}
C4 if (toks.length < 2) {0,1}
C5&&C6 if (toks[0].equals(INSTRUCTION_ADD)&&toks.length != 4) {00,01,10,11}
C7&&C8 if (toks[0].equals(INSTRUCTION_SUBTRACT)&&toks.length!= 4) {00,01,10,11}
C9&&C10 if (toks[0].equals(INSTRUCTION_MULT)&&toks.length!= 4) {00,01,10,11}
C11&&C12 if (toks[0].equals(INSTRUCTION_DIVIDE)&&toks.length!= 4) {00,01,10,11}
C13 if (toks[0].equals(INSTRUCTION_RETURN)) {0,1}
C14&&C15 if (toks[0].equals(INSTRUCTION_LOAD)&&toks.length!= 4) {00,01,10,11}
C16&&C17 if (toks[0].equals(INSTRUCTION_STORE)&&toks.length!= 4) {00,01,10,11}
C18&&C19 else if (toks[0].equals(INSTRUCTION_MOVE)&&toks.length != 3) {00,01,10,11}
C20&&C21 else if (toks[0].equals(INSTRUCTION_JUMP)&&toks.length != 2) {00,01,10,11}
C22&&C23 else if (toks[0].equals(INSTRUCTION_JZ)&&toks.length != 3) {00,01,10,11}
Then we consider the multiply-condition scoring.
And first we consider domain partitioning multiple-condition coverage and have the results is that we miss (0,1) and (1,1) in C3, miss (1)in C4,and we all miss (0,0) and (1,0) in C4…12,C14…C23,
So the score is 41/46=89.1%
And if we consider boundary analysis multiple-condition coverage and have the results is that we miss (1)in C4,and we all miss (0,0) and (1,0) in C4…12,C14…C23,
So the score is 43/46=93.5%

Task 7
I believe that boundary-value analysis method is more effective than equivalence partitioning, because we can use the more accurate values and more test cases, this can make our testing more effective, as we can see the input domain, the boundary-value analysis has a more detailed scope and a higher coverage, because the boundary value is defined and tested, and the output domain is more comprehensive. Moreover, the boundary-value analysis has a higher test coverage score. In summary, I think that boundary-value analysis is more effective than equivalence partitioning.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值