Training File IO: Difference between revisions

From STRIDE Wiki
Jump to navigation Jump to search
(Created page with '= Objectives = This Training Module is focused on leveraging File IO from the context of a Test Unit executing on a target. The module focuses on th…')
 
 
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
= Objectives =
== Objectives ==


This Training Module is focused on leveraging [[File_Transfer_Services | File IO]] from the context of a Test Unit executing on a target. The module focuses on the following:
This Training Module is focused on leveraging [[File_Transfer_Services | File IO]] from the context of a Test Unit executing on a target. The module covers the following:
* Accessing host based files
* Accessing host based files
* Read and Writing content to / from host files
* Read and Writing content to / from host files




There are two test files used -- '''TestFile.cpp & TestFile.h''' -- that contains one Test Unit:
There are two test files used -- '''TestFile.cpp & TestFile.h''' -- that implement one Test Unit:
* '''TestFile'''
* '''TestFile'''




The Test Unit has test cases already implemented (used for reference) and has one test method that you are required to implement (called '''Exercise''').  Currently this method is empty and using an ''NOT IN USE'' status.
The Test Unit has test cases already implemented (used for reference) and has one test method that you are required to implement (called '''Exercise''').  Currently this method is empty and returns a ''NOT IN USE'' status.


= Instructions =
== Instructions ==


== Build and Run TestApp ==
=== Build and Run TestApp ===


* Build TestApp using SDK makefile
* [[Building_an_Off-Target_Test_App#Build_Steps | Build TestApp]]  using SDK makefile
* Startup TestApp
* Startup TestApp
* Create an [[Stride_Runner#Options | option file]] (myoptions.txt) using the following content (Windows example)
* If you have not created an option file, please refer to [[Training_Getting_Started#Run_Training_Tests| setup]]  
 
  ##### Command Line Options ######
  --device "TCP:localhost:8000"
  --database %STRIDE_DIR%\SDK\Windows\out\TestApp.sidb
  --output %STRIDE_DIR%\SDK\Windows\sample_src\TestApp.xml
  --log_level all


* Execute ''Test File'' Test Unit only  
* Execute ''Test File'' Test Unit only  


   > stride -O myoptions.txt --run TestFile
   > stride --options_file myoptions.txt --run TestFile


   Loading database...
   Loading database...
Line 41: Line 35:
   Saving result file...
   Saving result file...


* Review the details of the test results using a Browser. Open '''TestApp.xml''' which can be found in the ''sample_src'' directory (based on the ''output'' option). By opening the xml file in a web browser the xsl is automatically applied to create html.
* Review the details of the test results using a Browser. Open [[Building_an_Off-Target_Test_App#Interpreting_Results | TestApp.xml ]] which can be found in the ''sample_src'' directory (based on the ''output'' option). By opening the xml file in a web browser the xsl is automatically applied to create html.


== Implement Exercise ==
=== Implement Exercise ===


* Read data content ''TestFileInput.dat'' file created from previous test method
* Read data content ''TestFileInput.dat'' file created from the previous test method (SDK\Windows or SDK/Posix).
* Make sure to Exit test if error occurs when opening file(s) (i.e. use '''srEXIT_XX''')
** ''Hint:'' You will probably want to read about [[File Transfer Services]]
* Make sure to Exit the test if an error occurs when opening file(s) (i.e. use '''srEXIT_XX''')
* Take a summation of the data content using ''sut_add()''  
* Take a summation of the data content using ''sut_add()''  
* Validate summation with content in ''TestFileSum.dat'' file
* Validate summation with content in ''TestFileSum.dat'' file
* Add a ''NOTE"" capturing important information such as ''bytes read'', ''summation'', etc. _
* Add a ''NOTE'' capturing important information such as ''bytes read'', ''summation'', etc. _
   
   


* Execute only ''TestFile''   
* Execute only ''TestFile''   


   > stride -O myoptions.txt --run TestFile
   > stride --options_file myoptions.txt --run TestFile


   Loading database...
   Loading database...
Line 67: Line 62:
   Saving result file...
   Saving result file...


== Run and Publish Results ==
=== Run and Publish Results ===


When you have completed the Exercise(s) publish your results to Test Space. To make it easier for now we recommend that you update your existing option file (myoptions.txt) with the following:
When you have completed the Exercise(s) publish your results to Test Space. If you have not added test space options to your options file (<tt>myoptions.txt</tt>) please see [[Training_Getting_Started#Test_Space_Access| testspace access]].


  #### Test Space options (partial) #####
   > stride --options_file myoptions.txt --run TestFile --space TestFile --upload
  #### Note - make sure to change username, etc. ####
  --testspace https://username:password@yourcompany.stridetestspace.com
  --project Training
  --name YOURNAME
 
   > stride -O myoptions.txt --run TestFile --space TestFile --upload


Note: This space has been set up with a Baseline of [[Training_Getting_Started#Test_Space_Access | ''expected test results'']] that you can use to validate your results.
Note: This space has been set up with a Baseline of [[Training_Getting_Started#Test_Space_Access | ''expected test results'']] that you can use to validate your results.


= Reference =
== Reference ==
The following reference information is related to passing parameters to Test Units.
The following reference information is related to passing parameters to Test Units.


== Wiki ==
=== Wiki ===
* [[File_Transfer_Services | File Transfer Services]] - important information for using file operations on host file from test code executing on the target
* [[File_Transfer_Services | File Transfer Services]] - important information for using file operations on host file from test code executing on the target
** Review ''srFileOpen()'' and ''srFileClose()''
** Review ''srFileOpen()'' and ''srFileClose()''
Line 90: Line 79:
** Other references as needed
** Other references as needed


== Samples ==
=== Samples ===
* [[File_Services_Sample | File Services Sample]] - presents a few basic examples of how to use the File Transfer Services API to interact with the host file system.  
* [[File_Services_Sample | File Services Sample]] - presents a few basic examples of how to use the File Transfer Services API to interact with the host file system.  



Latest revision as of 19:02, 1 February 2013

Objectives

This Training Module is focused on leveraging File IO from the context of a Test Unit executing on a target. The module covers the following:

  • Accessing host based files
  • Read and Writing content to / from host files


There are two test files used -- TestFile.cpp & TestFile.h -- that implement one Test Unit:

  • TestFile


The Test Unit has test cases already implemented (used for reference) and has one test method that you are required to implement (called Exercise). Currently this method is empty and returns a NOT IN USE status.

Instructions

Build and Run TestApp

  • Build TestApp using SDK makefile
  • Startup TestApp
  • If you have not created an option file, please refer to setup
  • Execute Test File Test Unit only
 > stride --options_file myoptions.txt --run TestFile
 Loading database...
 Connecting to device...
 Executing...
   test unit "TestFile"
     > 0 passed, 0 failed, 0 in progress, 1 not in use.
   --------------------------------------------------------------
   Summary: 0 passed, 0 failed, 0 in progress, 1 not in use.

 Disconnecting from device...
 Saving result file...
  • Review the details of the test results using a Browser. Open TestApp.xml which can be found in the sample_src directory (based on the output option). By opening the xml file in a web browser the xsl is automatically applied to create html.

Implement Exercise

  • Read data content TestFileInput.dat file created from the previous test method (SDK\Windows or SDK/Posix).
  • Make sure to Exit the test if an error occurs when opening file(s) (i.e. use srEXIT_XX)
  • Take a summation of the data content using sut_add()
  • Validate summation with content in TestFileSum.dat file
  • Add a NOTE capturing important information such as bytes read, summation, etc. _


  • Execute only TestFile
 > stride --options_file myoptions.txt --run TestFile
 Loading database...
 Connecting to device...
 Executing...
   test unit "TestFile"
     > 1 passed, 0 failed, 0 in progress, 0 not in use.
   --------------------------------------------------------------
   Summary: 1 passed, 0 failed, 0 in progress, 0 not in use.
  
 Disconnecting from device...
 Saving result file...

Run and Publish Results

When you have completed the Exercise(s) publish your results to Test Space. If you have not added test space options to your options file (myoptions.txt) please see testspace access.

  > stride --options_file myoptions.txt --run TestFile --space TestFile --upload

Note: This space has been set up with a Baseline of expected test results that you can use to validate your results.

Reference

The following reference information is related to passing parameters to Test Units.

Wiki

  • File Transfer Services - important information for using file operations on host file from test code executing on the target
    • Review srFileOpen() and srFileClose()
    • Review srFileRead() and srFileWrite()
    • Other references as needed

Samples

  • File Services Sample - presents a few basic examples of how to use the File Transfer Services API to interact with the host file system.