FileTransfer Sample

From STRIDE Wiki
Jump to navigation Jump to search

Introduction

This example demonstrates a simple technique to enable file transfers between the host and target device through the use of helper functions that invoke File Transfer Services APIs. These techniques are particularly useful for devices that don't have externally accessible file systems as a way to transfer large volumes of data to/from the device for the purpose of testing (e.g. media data when testing a media player application).

Source (helper utilities)

s2_filetransfer_util.c / h

These files implement the following functions to read from and write to the host filesystem:

readFromHost
reads a specified file path from the host and creates a stdio temporary file handle with the contents of the file.
writeToHost
writes the contents of a filehandle to the specified host path.
FileLoopback
remotely callable function that takes two paths - the file to read from and the file to write to (will be created). This function is called by our test to cause files to be transferred to/from the host.

Tests Description

s2_filetransfer_testmodule

This test module implements a single test that shows how to invoke a remote helper function to initiate the transfer of files. The test scenario illustrates some of the techniques available to transfer files using the STRIDE services.

file_loopback

This test does the following:

  1. creates a text file containing random characters
  2. invokes the remote function FileLoopback, specifying the file we created as input and a new file name as output (to be created by the software on device).
  3. verifies that the output file was created and that it matches the original input file.