Kết quả thực hiện chƣơng trình kiểmthử

Một phần của tài liệu Các kỹ thuật kiểm thử phần mềm nhúng và ứng dụng (Trang 55 - 74)

Từ giao diện debug chương trình, tôi tiến hành thực hiện kiểm thử theo các bước của từng test case tương ứng với từng hàm. Xem xét các giá trị hiển thị trong các vùng “Memory”, “Variables”, “Registers” của trình biên dịch CodeWarrior đặc biệt là biến “testResult” để biết kết quả thực hiện test case là PASS hay FAIL.

Hình 3. 11: Kết quả thực hiện chương trình được trả về qua biến testResult

Qua quá trình chạy chương trình kết quả thu được là tất cả các Test Case đều PASS. Kết quả thực hiện kiểm thử được lưu trong file “Test Cases List and Report Results.excel”. Từ kết quả kiểm thử cho thấy rằng các hàm trong phần mềm SSD đã thực hiện được các yêu cầu, đảm bảo chạy đúng như mong đợi. Người dùng có thể an tâm sử dụng các hàm này.

KẾT LUẬN

Trong quá trình thực hiện luận văn tôi đã được tìm hiểu về lĩnh vực kiểm thử phần mềm. Nắm được khái niệm, quy trình kiểm thử phần mềm cơ bản, các mức kiểm thử phần mềm và một số chiến lược kiểm thử phần mềm nói chung.

Tôi đã nghiên cứu, tìm hiểu tổng quan về hệ thống nhúng và phần mềm nhúng. Đặc biệt là các kỹ thuật kiểm thử phần mềm nhúng. Ngày nayhệ thống nhúng và phần mềm nhúng đang dần trở thành một ngành phát triển mạnh mẽ trong lĩnh vực công nghệ thông tin,với những ứng dụng rộng rãi trong công nghiệp và đời sống. Vì vậy kiểm thử phần mềm nhúng càng trở nên quan trọng, việc nghiên cứu các kỹ thuật này có thể áp dụng để kiểm thử các phần mềm nhúng trong các hệ thống nhúng.

Tôi cũng đã có sự tìm hiểu so sánh đánh giá kiểm thử phần mềm nhúng với kiểm thử phần mềm nói chung để thấy được những khó khăn trong việc kiểm thử phần mềm nhúng.

Ngoài ra tôi đã áp dụng các kỹ thuật kiểm thử phần mềm nhúngđã nghiên cứu cụ thể là kỹ thuật thiết kế kiểm thử - Kiểm thử điều khiển luồng để tiến hành kiểm thử phần mềm điều khiển chuẩn cho mô-đun flash của mạch MKL46Z256. Từ việc viết tài liệu mô tả chi tiết yêu cầu của từng hàm, vẽ sơ đồ khối của từng hàm cho phần mềm này đến việc viết chương trình phần mềm, thiết kế test case, viết chương trình cho từng test case, thực hiện kiểm thử và báo cáo kết quả. Mục đích là ứng dụng các kỹ thuật kiểm thử phần mềm nhúng đã nghiên cứu vào thực tế, giúp cho mọi người hiểu được rõ hơn việc kiểm thử phần mềm nhúng.

PHỤ LỤC

Phụ lục A: Tài liệu thiết kế chi tiết của phần mềm SSD 1.FlashCommandSequence()

1.1 Tổng quan

Hàm này được dùng để thực hiện ghi chuỗi lệnh xuống flash.

1.2 Prototype

UINT32 FlashCommandSequence (PFLASH_SSD_CONFIG PSSDConfig, \ UINT8 index, \

UINT8* pCommandArray)

1.3 Giá trị trả về

Bảng 1: Các giá trị trả về của hàm FlashCommandSequence()

Kiểu dữ liệu

Mô tả Các giá trị có thể trả về

UINT32 Thực hiện thành công FTFx_OK

Giá trị lỗi FTFx_ERR_ACCERR

FTFx_ERR_PVIOL FTFx_ERR_MGSTAT0

BEGIN

Check if the CCIF bit is

set

Check if FPVIOL or ACCERR bits

are set

Clear the PVIOL or/and ACCERR bits Yes

Yes

Write to FCCOB register to load the required command parameter.

No (adsbygoogle = window.adsbygoogle || []).push({});

More Parameters?

Clear the CCIF bit in FSTAT register to launch the command

Read FSTAT register

Check if CCIF bit is set No END Check if the ACCERR bit is set in the FSTAT

register

Return code to state 'FTFx_ERR_ACCERR' Yes

Check if the FPVIOL bit

is set

Return code to state 'FTFx_ERR_PVIOL'

Check if the MGSTAT0 bit is

set No

Return code to state ‘FTFx_ERR_MGSTAT0’

No

set returnCode to 'FTFx_OK'

FlashCommandSequence()

Read Flash status register

No Yes No Yes Yes Yes

Call CallBack function if it is set

No

2.FlashEraseAllBlock() 2. 1 Tổng quan

Hàm này sẽ xoá tất cả bộ nhớ flash, kiểm tra toàn bộ nội dung bộ nhớ flash và trả về trạng thái bảo mật của chip.

FlashEraseAllBlock() sẽ bị huỷ và trả về lỗi nếu có bất kỳ một vùng của bộ nhớ flash ở trạng thái được bảo vệ (Protected).

2.2 Prototype

UINT32 FlashEraseAllBlock (PFLASH_SSD_CONFIG PSSDConfig, \ pFLASHCOMMANDSEQUENCE FlashCommandSequence)

2.3 Giá trị trả về

Bảng2: Các giá trị trả về của hàm FlashEraseAllBlock()

Kiểu dữ liệu

Mô tả Các giá trị có thể trả về

UINT32 Thực hiện thành công FTFx_OK

Giá trị lỗi FTFx_ERR_PVIOL (adsbygoogle = window.adsbygoogle || []).push({});

2.4 Sơ đồ khối

BEGIN

END

Prepare passing parameters for FlashCommandSquence API

Return with returnCode Call the

FlashCommandSequence for erase all block

FlashEraseAllBlock()

Set the returncode to state "OK"

Hình A. 2: Sơ đồ khối của hàm FlashEraseAllBlock()

3. FlashEraseSector() 3.1 Tổng quan

Hàm này cho phép xoá tất cả địa chỉ của một hoặc nhiều sector trong bộ nhớ P- Flash.

FlashEraseSector() sẽ bị huỷ và trả về lỗi nếu vùng được chọn để xoá ở trạng thái được bảo vệ (Protected).

UINT32 FlashEraseSector(PFLASH_SSD_CONFIG PSSDConfig, \ UINT32 destination, \

UINT32 size, \

pFLASHCOMMANDSEQUENCE FlashCommandSequence)

3.3 Giá trị trả về

Bảng3: Các giá trị trả về của hàm FlashEraseSector()

Kiểu dữ liệu

Mô tả Các giá trị có thể trả về

UINT32 Thực hiện thành công FTFx_OK

Giá trị lỗi FTFx_ERR_ACCERR

FTFx_ERR_ADDR FTFx_ERR_SIZE FTFx_ERR_RANGE FTFx_ERR_PVIOL

BEGIN Call the FlashCommandSequence Check if target address is aligned? No END Return with returnCode Prepare passing parameters for FlashCommandSquence

for sector erase

FlashEraseSector()

Check if end address is within

valid range

No

Return code to state ‘invalid address’

Return code to state ‘invalid range’ Set Return code to (adsbygoogle = window.adsbygoogle || []).push({});

‘OK’ Check if size > 0 Check if return code is "OK" Yes Yes Yes No Check if size is aligned on sector size

Return code to state ‘invalid size’ Yes

Yes

No

Updated size and target address

No Check

if target address is within valid range

Yes

Return code to state ‘invalid range’ No

4. FlashVerifyAllBlock() 4.1 Tổng quan

Hàm này sẽ kiểm tra xem tất cả nội dung bộ nhớ P-Fl ash đã được xoá hay chưa với các mức read margin được chỉ định.

Read Margin Choice có 3 mức:

 Read margin choice = 0x0: Use the „Normal‟ read level  Read margin choice = 0x1: Use the „User‟ read

 Read margin choice = 0x2: Use the „Factory‟ read

FlashVerifyAllBlock() sẽ trả về lỗi nếu tất cả nội dunghoặc một phần bộ nhớ flash không ở trạng thái được xoá (erased).

4.2 Prototype

UINT32 FlashVerifyAllBlock (PFLASH_SSD_CONFIG PSSDConfig, \ UINT8 marginLevel, \

pFLASHCOMMANDSEQUENCE FlashCommandSequence)

4.3 Giá trị trả về

Bảng4: Các giá trị trả về của hàm FlashVerifyAllBlock()

Kiểu dữ liệu

Mô tả Các giá trị có thể trả về

UINT32 Thực hiện thành công FTFx_OK

Giá trị lỗi FTFx_ERR_ACCERR

FTFx_ERR_MGSTAT0 4.4 Sơ đồ khối BEGIN Call the FlashCommandSequence END

Return with returnCode Prepare passing parameters for FlashCommandSquence

for Verify all Block

FlashVerifyAllBlock()

Set Return code to ‘OK’

5. FlashVerifySection() 5.1 Tổng quan (adsbygoogle = window.adsbygoogle || []).push({});

Hàm này sẽ kiểm tra xem một vùng (1 sector) bộ nhớ P-Flash đã được xoá hay chưa với các mức readmargin được chỉ định.

Read Margin Choice có 3 mức:

 Read margin choice = 0x0: Use the „Normal‟ read level  Read margin choice = 0x1: Use the „User‟ read

 Read margin choice = 0x2: Use the „Factory‟ read

FlashVerifySection() sẽ trả về lỗi nếu vùngđược chọn để xoá không ở trạng thái được xoá (erased).

5.2 Prototype

UINT32 FlashVerifySection (PFLASH_SSD_CONFIG PSSDConfig, \ UINT32 destination, \

UINT16 Number, \ UINT8 marginLevel, \

pFLASHCOMMANDSEQUENCE FlashCommandSequence)

5.3 Giá trị trả về

Bảng5: Các giá trị trả về của hàm FlashVerifySection()

Kiểu dữ liệu

Mô tả Các giá trị có thể trả về

UINT32 Thực hiện thành công FTFx_OK

Giá trị lỗi FTFx_ERR_ACCERR

FTFx_ERR_ADDR FTFx_ERR_RANGE FTFx_ERR_MGSTAT0

BEGIN

Call the FlashCommandSequence

END Return with returnCode Prepare passing parameters for FlashCommandSquence

for section verify

FlashVerifySection()

Check if end address is within

valid range

No Return code to state ‘invalid range’ Set Return code to

‘OK’

Yes Check if target address is

phrase aligned?

Return Code to state 'invalid address'

Yes

No Check (adsbygoogle = window.adsbygoogle || []).push({});

if target address is within valid range

Yes

Return code to state ‘invalid range’ No

Hình A. 5: Sơ đồ khối của hàm FlashVerifySection()

6. FlashProgramCheck() 6.1 Tổng quan

Hàm này sẽ kiểm tra việc ghi dữ liệu vào bộ nhớ P-Flash trước đó có đúng hay không với mức margin được chỉ định.

Read Margin Choice có 2 mức:

 Read margin choice = 0x1: Use the „User‟ read  Read margin choice = 0x2: Use the „Factory‟ read

FlashProgramCheck() sẽ trả về lỗi nếu việc so sánh dữ liệu thực tế đọc ra từ flash được ghi vào trước đó với dữ liệu mong đợi được truyền vào qua các thanh ghi không giống nhau.

6.2 Prototype

UINT32FlashProgramCheck (PFLASH_SSD_CONFIG PSSDConfig, \ UINT32 destination, \ UINT32 size, \ UINT8* pExpectedData, \ UINT32* pFailAddr, \ UINT8 marginLevel, \ pFLASHCOMMANDSEQUENCE FlashCommandSequence) 6.3 Giá trị trả về

Bảng6: Các giá trị trả về của hàm FlashProgramCheck()

Kiểu dữ liệu

Mô tả Các giá trị có thể trả về

UINT32 Thực hiện thành công FTFx_OK

Giá trị lỗi FTFx_ERR_ACCERR

FTFx_ERR_ADDR FTFx_ERR_SIZE FTFx_ERR_RANGE FTFx_ERR_MGSTAT0

BEGIN

Call the FlashCommandSequence

END

Prepare passing parameters for FlashCommandSquence

for Program Check

FlashProgramCheck()

Check

if target address is within valid range

No Return code to state ‘invalid range’

Yes Check if target address is

longword aligned?

Return Code to state 'invalid address' No Check if size is longword aligned? Yes Yes

Return code to state ‘invalid size’ No Check if size > 0 Yes Check if return code is "OK" No (adsbygoogle = window.adsbygoogle || []).push({});

Updated size, destination and pExpectedData

Yes

No Set Return code to

‘OK’

Updated pFailAddr

Return with returnCode

7. FlashProgramLongword() 7.1 Tổng quan

Hàm này được dùng để ghi 4 byte dữ liệu liên tiếp vào bộ nhớ P-Flash.

FlashProgramLongword() sẽ trả về lỗi nếu vùng được chọn để ghidữ liệu vào bộ nhớ flash ở trạng thái được bảo vệ (Protected).

7.2 Prototype

UINT32FlashProgramLongword (PFLASH_SSD_CONFIG PSSDConfig, \ UINT32 destination, \

UINT32 size, \

UINT8* pData, \

pFLASHCOMMANDSEQUENCE FlashCommandSequence)

7.3 Giá trị trả về

Bảng7: Các giá trị trả về của hàm FlashProgramLongword()

Kiểu dữ liệu

Mô tả Các giá trị có thể trả về

UINT32 Thực hiện thành công FTFx_OK

Giá trị lỗi FTFx_ERR_ACCERR

FTFx_ERR_ADDR FTFx_ERR_PVIOL FTFx_ERR_SIZE FTFx_ERR_RANGE

BEGIN

Check if target address is within

valid range

No

Yes

Prepare passing parameters for FlashCommandSequence to perform the

FlashProgramLongword

Call FlashCommandSequence to perform the required command

END FlashProgramLongword() Check if return code is "OK" No Check if size > 0 Yes No Check if size is longword aligned? Yes Check if target address is longword aligned? (adsbygoogle = window.adsbygoogle || []).push({});

Return code to state ‘invalid address’ No

Yes

Yes

No

Return Code to state 'invalid size'

Return Code to state 'invalid range’

Updated size, destination and pData

Return with returnCode Set return Code to

'OK'

8. PFlashGetProtection() 8. 1 Tổng quan

Hàm này lấy ra trạng thái bảo vệ hiện tại của P-Flash.

8.2 Prototype

UINT32 PFlashGetProtection(PFLASH_SSD_CONFIG pSSDConfig, \ UINT32* protectStatus)

8.3 Giá trị trả về

Bảng 8: Các giá trị trả về của hàm PFlashGetProtection() Kiểu dữ

liệu

Mô tả Các giá trị có thể trả về

UINT32 Thực hiện thành công FTFx_OK

8.4 Sơ đồ khối

BEGIN

END

Store the value of FPROT register in the designated

variable

PFlashGetProtection()

Read FPROT registers value

Return FTFx_OK

Hình A. 8: Sơ đồ khối của hàm PFlashGetProtection()

9. PFlashSetProtection() 9. 1 Tổng quan

Hàm này thiết lập bảo vệ vùng P-Flash theo trạng thái bảo vệ mong đợi. Việc thiết lập trạng thái bảo vệ cho vùng P-Flash được thực hiện thành công khi tăng vùng P-Flash cần bảo vệ trong phạm vi cho phép. Nếu giảm vùng P-Flash cần bảo vệ sẽ trả về lỗi và trạng thái bảo vệ hiện tại sẽ không được thay đổi. Muốn P-Flash trở về trạng thái ban đầu thì phải khởi động lại mạch.

9.2 Prototype (adsbygoogle = window.adsbygoogle || []).push({});

UINT32 PFlashSetProtection(PFLASH_SSD_CONFIG pSSDConfig, \ UINT32 protectStatus)

9.3 Giá trị trả về

Bảng 9: Các giá trị trả về của hàm PFlashSetProtection() Kiểu dữ

liệu

Mô tả Các giá trị có thể trả về

UINT32 Thực hiện thành công FTFx_OK

Giá trị lỗi FTFx_ERR_CHANGEPROT

9.4 Sơ đồ khối

BEGIN

END Return with returnCode

PFlashSetProtection()

Set return Code to 'OK' Write the new protection value in

the FPROT registers

Yes Check

if the requested protection status transition is a valid

possibility

Return code to state ‘ERR_CHANGEPROT’ No

Hình A. 9: Sơ đồ khối của hàm PFlashSetProtection()

Phụ lục B: Danh sách test case của từng hàm trong phần mềm SSD

Test case No.

Function Name Description

1.1

FlashEraseAllBlock()

To demonstrate that FlashEraseAllBlock() will return OK if the Flash is unprotected.

1.2

To demonstrate that FlashEraseAllBlock() will return an error if any region of the P-Flash memory is protected.

2.1

FlashEraseSector()

To demonstrate that FlashEraseSector() will return an error if Flash destination is out of valid range on Pflash.

2.2 (adsbygoogle = window.adsbygoogle || []).push({});

To demonstrate that FlashEraseSector() will return an error if Flash address is not sector aligned.

2.3 To demonstrate that FlashEraseSector() will return an error if the size is not sector aligned. 2.4

To demonstrate that FlashEraseSector() will return an error if size makes out of valid range on Pflash.

2.5

To demonstrate that FlashEraseSector will return OK if user wants to erase on Pflash with sector size = 0.

2.6

To demonstrate that FlashEraseSector will return OK if all parameters is valid. The flash is

unprotected. 2.7

To demonstrate that FlashEraseSector() will return an error if user wants to erase protected flash sector on Pflash.

3.1

FlashVerifyAllBlock()

To demonstrate that FlashVerifyAllBlock() will return an error if user provides invalid margin level.

3.2

To demonstrate that FlashVerifyAllBlock() will return OK if entire memory is erased (test with different margin level )and there is no area protected.

3.3

To demonstrate that FlashVerifyAllBlock() will return an error if there is any non blanked

location on Pflash and there is no area protected. 3.4

To demonstrate that FlashVerifyAllBlock() will return OK if entire memory is erased (test with different margin level )and some location on Pflash is protected.

3.5

To demonstrate that FlashVerifyAllBlock() will return error if there is any non blanked location on Pflash and this non blanked location on Pflash is protected.

4.1

FlashVerifySection()

To demonstrate that FlashVerifySection() will return an error if invalid margin level provided on PFlash.

4.2

To demonstrate that FlashVerifySection() will return an error if misaligned destination provided on Pflash. Test with all margin levels.

4.3

To demonstrate that FlashVerifySection() will return an error if input provided make destination to be out of range on Pflash.

4.4

To demonstrate that FlashVerifySection() will return an error if input provided make end address to be out of range on Pflash.

4.5 (adsbygoogle = window.adsbygoogle || []).push({});

To demonstrate that FlashVerifySection() will return an error if requested number of longword is zero on Pflash. Test with all margin levels. 4.6

To demonstrate that FlashVerifySection() will return OK if the section to be verified is blanked and there is no area protected.

4.7

To demonstrate that FlashVerifySection() will return an error if the section to be verified is non blanked and there is no area protected.

4.8

To demonstrate that FlashVerifySection() will return OK if the section to be verified is blanked and this section on Pflash is protected.

4.9

To demonstrate that FlashVerifySection() will return an error if the section to be verified is non blanked and this section on Pflash is protected. 5.1

FlashProgramCheck()

To demonstrate that FlashProgramCheck() will return an error if margin level provided by user is invalid.

5.2

To demonstrate that FlashProgramCheck() will return an error if destination provided by user is not algined on Pflash.

5.3

To demonstrate that FlashProgramCheck() will return an error if size provided by user is not algined on Pflash.

5.4

To demonstrate that FlashProgramCheck() will return an error if destination provided by user makes out of flash range on Pflash.

5.5

To demonstrate that FlashProgramCheck() will return an error if size provided by user makes out of flash range on Pflash.

5.6

To demonstrate that FlashProgramCheck() will return an error if destination is mismatched to source data. In this case, FailAddr will report the fisrt failing addr.

5.7

To demonstrate that FlashProgramCheck() will return OK if user want to program check with size = 0.

5.8

To demonstrate that FlashProgramCheck() will return OK if destination is matched to source data. User provided arguments are valid. 6.1 FlashProgramLongword()

To demonstrate that FlashProgramLongword() will return an error if destination provided by user is not longword aligned.

6.2

To demonstrate that FlashProgramLongword() will return an error if size provided by user is not longword aligned.

6.3

To demonstrate that FlashProgramLongword() will return an error if destination provided by user makes out of flash range on Pflash. 6.4

To demonstrate that FlashProgramLongword() will return an error if size provided by user makes out of flash range on Pflash. (adsbygoogle = window.adsbygoogle || []).push({});

6.5 To demonstrate that FlashProgramLongword() will return OK if the Flash is unprotected. 6.6

To demonstrate that FlashProgramLongword() will return OK if user want to program with size = 0 to entire Pflash.

6.7

To demonstrate that FlashProgramLongword() will return an error if user want to program to protected area on Pflash.

7.1

PFlashGetSetProtection()

To demonstrate that PFlashGetProtection() and PFlashSetProtection() can set the protection status to some areas of Flash.

7.2

To demonstrate that PFlashSetProtection() can increase the protection range of Flash and return FTFx_OK.

7.3

To demonstrate that PFlashSetProtection() can not decrease the protection range of Flash and return FTFx_ERR_CHANGEPORT.

TÀI LIỆU THAM KHẢO

Tiếng Anh

[1] Bart Broekman and Edwin Notenboon, Testing Embedded Software First Published in Great Britain in 2003.

[2] David E. Simon, An Embedded Software Primer, Person Education Publishing. [3]Freescale, KL46P121M48SF4__Reference_Manaual, July 2013.

[4] Glenford J. Myers, Tom Badgett, Corey Sandler, The Art of Software Testing,

Third Edition, John Wiley and Sons, Inc.

[5] Ilene Burnstein, Practical Software Testing, 2003 springer – Verlag New York. [6] Melissa Hunter, Production Flash Programming Best Practices for Kinetis K- and

Một phần của tài liệu Các kỹ thuật kiểm thử phần mềm nhúng và ứng dụng (Trang 55 - 74)