]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Application/ShellLibTestApp/sa3.c
updating comments mostly. also added some new lib functions.
[mirror_edk2.git] / ShellPkg / Application / ShellLibTestApp / sa3.c
index ae677b4dfaeea0b74ec20448e5aad6a6189fb7bc..bc7986a97ae85a3a8e32ab3bfaed6ed7d656abb8 100644 (file)
@@ -3,7 +3,7 @@
 \r
   This should be executed with "/Param2 Val1" and "/Param1" as the 2 command line options!\r
 \r
-  Copyright (c) 2008, Intel Corporation                                                         \r
+  Copyright (c) 2008-2009, Intel Corporation                                                         \r
   All rights reserved. This program and the accompanying materials                          \r
   are licensed and made available under the terms and conditions of the BSD License         \r
   which accompanies this distribution.  The full text of the license may be found at        \r
 **/\r
 \r
 #include <Uefi.h>\r
+#include <Guid/FileInfo.h>\r
+#include <Protocol/SimpleFileSystem.h>\r
+#include <Protocol/LoadedImage.h>\r
+#include <Protocol/EfiShellInterface.h>\r
+#include <Protocol/EfiShellEnvironment2.h>\r
+#include <Protocol/EfiShell.h>\r
+#include <Protocol/EfiShellParameters.h>\r
 #include <Library/UefiApplicationEntryPoint.h>\r
 #include <Library/UefiLib.h>\r
 #include <Library/ShellLib.h>\r
@@ -24,6 +31,8 @@
 SHELL_PARAM_ITEM ParamList[] = {\r
   {L"/Param1", TypeFlag},\r
   {L"/Param2", TypeValue},\r
+  {L"/Param3", TypeDoubleValue},\r
+  {L"/Param4", TypeMaxValue},\r
   {NULL, TypeMax}};\r
 \r
 /**\r
@@ -52,20 +61,41 @@ UefiMain (
   EFI_FILE_INFO       *pFileInfo;\r
   UINT64              Size;\r
   BOOLEAN             NoFile;\r
-  EFI_SHELL_FILE_INFO *pShellFileInfo, *pShellFileInfo2;\r
+  EFI_SHELL_FILE_INFO *pShellFileInfo;\r
   LIST_ENTRY          *List;\r
+  // CONST CHAR16              *Tester;\r
   \r
   FileHandle = NULL;\r
   StrCpy(FileName, L"testfile.txt");\r
-  Position = 0;\r
+//  Position = 0;\r
   pFileInfo = NULL;\r
   Size = 0;\r
   NoFile = FALSE;\r
   pShellFileInfo = NULL;\r
   List = NULL;\r
 \r
+  // command line param functions\r
+  Status = ShellCommandLineParse(ParamList, &List, NULL, FALSE);\r
+  // if you put an invalid parameter you SHOULD hit this assert.\r
+  ASSERT_EFI_ERROR(Status);\r
+  if (List) {\r
+    ASSERT(ShellCommandLineGetFlag(List, L"/Param5") == FALSE);\r
+    ASSERT(ShellCommandLineGetFlag(List, L"/Param1") != FALSE);\r
+    ASSERT(StrCmp(ShellCommandLineGetValue(List, L"/Param2"), L"Val1")==0);\r
+    ASSERT(StrCmp(ShellCommandLineGetRawValue(List, 0), L"SimpleApplication.efi")==0);\r
+    // Tester = ShellCommandLineGetValue(List, L"/Param3");\r
+    // Tester = ShellCommandLineGetValue(List, L"/Param4");\r
+\r
+    ShellCommandLineFreeVarList(List);\r
+  } else {\r
+    Print(L"param checking skipped.\r\n");\r
+  }\r
+\r
+//  return (EFI_SUCCESS);\r
+\r
+\r
   ASSERT(ShellGetExecutionBreakFlag() == FALSE);\r
-  ASSERT(StrCmp(ShellGetCurrentDir(NULL), L"f8:\\") == 0);\r
+  ASSERT(StrCmp(ShellGetCurrentDir(NULL), L"f10:\\") == 0);\r
   Print(L"execution break and get cur dir - pass\r\n");\r
 \r
   ShellSetPageBreakMode(TRUE);\r
@@ -97,7 +127,6 @@ UefiMain (
   FreePool(pFileInfo);\r
   pFileInfo = NULL;\r
   Status = ShellCloseFile(&FileHandle);\r
-  ASSERT(FileHandle == NULL);\r
   ASSERT_EFI_ERROR(Status);\r
   Print(L"read, write, create, getinfo - pass\r\n");\r
 \r
@@ -125,7 +154,6 @@ UefiMain (
   ASSERT(Size == 0x20);\r
   ASSERT_EFI_ERROR(Status);\r
   Status = ShellCloseFile(&FileHandle);\r
-  ASSERT(FileHandle == NULL);\r
   ASSERT_EFI_ERROR(Status);\r
   Print(L"setinfo and change size, getsize - pass\r\n");\r
   \r
@@ -145,7 +173,6 @@ UefiMain (
   FreePool(pFileInfo);\r
   pFileInfo = NULL;   \r
   Status = ShellDeleteFile(&FileHandle);\r
-  ASSERT(FileHandle == NULL);\r
   ASSERT_EFI_ERROR(Status);\r
   Print(L"reopen file - pass\r\n");\r
 \r
@@ -163,7 +190,6 @@ UefiMain (
   ASSERT((pFileInfo->Attribute&EFI_FILE_DIRECTORY)==0);\r
   FreePool(pFileInfo);\r
   Status = ShellDeleteFile(&FileHandle);\r
-  ASSERT(FileHandle == NULL);\r
   ASSERT_EFI_ERROR(Status);\r
   Print(L"size of empty - pass\r\n");\r
 \r
@@ -183,7 +209,6 @@ UefiMain (
   ASSERT(StrCmp(pFileInfo->FileName, FileName) == 0);\r
   ASSERT(pFileInfo->Attribute&EFI_FILE_DIRECTORY);\r
   Status = ShellDeleteFile(&FileHandle);\r
-  ASSERT(FileHandle == NULL);\r
   ASSERT_EFI_ERROR(Status);\r
   Print(L"Directory create - pass\r\n");\r
   \r
@@ -206,7 +231,7 @@ UefiMain (
                                0\r
                                );\r
   ASSERT_EFI_ERROR(Status);\r
-  Status = ShellFindFirstFile(FileHandle, pFileInfo);\r
+  Status = ShellFindFirstFile(FileHandle, &pFileInfo);\r
   ASSERT_EFI_ERROR(Status);\r
   Status = ShellFindNextFile(FileHandle, pFileInfo, &NoFile);\r
   ASSERT_EFI_ERROR(Status);\r
@@ -216,9 +241,8 @@ UefiMain (
   ASSERT(NoFile == FALSE);\r
   Status = ShellFindNextFile(FileHandle, pFileInfo, &NoFile);\r
   ASSERT_EFI_ERROR(Status);\r
-  /// @todo - why is NoFile never set? limitation of NT32 file system?\r
+  ///@todo - why is NoFile never set? limitation of NT32 file system?\r
   Status = ShellDeleteFile(&FileHandle);\r
-  ASSERT(FileHandle == NULL);\r
   ASSERT(Status == RETURN_WARN_DELETE_FAILURE);\r
   Print(L"FindFirst - pass\r\n");\r
   Print(L"FindNext - Verify with real EFI system.  Cant verify NoFile under NT32\r\n");\r
@@ -233,10 +257,7 @@ UefiMain (
   ASSERT(pShellFileInfo->Info->FileSize == 0);\r
   ASSERT(StrCmp(pShellFileInfo->Info->FileName, L"File.txt") == 0);\r
   ASSERT(pShellFileInfo->Info->Attribute == 0);\r
-  pShellFileInfo2 = (EFI_SHELL_FILE_INFO*)0x12345678;\r
-  Status = ShellOpenFileMetaArg(L"testDir\\*.*", EFI_FILE_MODE_READ, &pShellFileInfo2);\r
-  ASSERT(pShellFileInfo2 == NULL);\r
-  ASSERT(Status == EFI_UNSUPPORTED);\r
+\r
   Status = ShellCloseFileMetaArg(&pShellFileInfo);\r
   ASSERT_EFI_ERROR(Status);\r
   Print(L"Open/Close Meta Arg - pass\r\n");\r
@@ -250,7 +271,6 @@ UefiMain (
                                );\r
   ASSERT_EFI_ERROR(Status);\r
   Status = ShellDeleteFile(&FileHandle);\r
-  ASSERT(FileHandle == NULL);\r
   StrCpy(FileName, L"testDir");\r
   ASSERT_EFI_ERROR(Status);\r
   Status = ShellOpenFileByName(FileName, \r
@@ -259,12 +279,11 @@ UefiMain (
                                0\r
                                );\r
   Status = ShellDeleteFile(&FileHandle);\r
-  ASSERT(FileHandle == NULL);\r
   ASSERT_EFI_ERROR(Status);\r
 \r
   // get environment variable\r
   // made for testing under nt32\r
-  ASSERT(StrCmp(ShellGetEnvironmentVariable(L"path"), L".;f8:\\efi\\tools;f8:\\efi\\boot;f8:\\;f9:\\efi\\tools;f9:\\efi\\boot;f9:\\") == 0);\r
+  ASSERT(StrCmp(ShellGetEnvironmentVariable(L"path"), L".;f10:\\efi\\tools;f10:\\efi\\boot;f10:\\;f9:\\efi\\tools;f9:\\efi\\boot;f9:\\") == 0);\r
   Print(L"ShellGetEnvironmentVariable - pass\r\n");\r
 \r
   // set environment variable\r
@@ -277,21 +296,6 @@ UefiMain (
   ASSERT_EFI_ERROR(Status);\r
   // the pass printout for this is performed by EmptyApplication\r
   Print(L"\r\n");\r
-    \r
-  // command line param functions\r
-  Status = ShellCommandLineParse(ParamList, &List, NULL, FALSE);\r
-  // if you put an invalid parameter you SHOULD hit this assert.\r
-  ASSERT_EFI_ERROR(Status);\r
-  if (List) {\r
-    ASSERT(ShellCommandLineGetFlag(List, L"/Param5") == FALSE);\r
-    ASSERT(ShellCommandLineGetFlag(List, L"/Param1") != FALSE);\r
-    ASSERT(StrCmp(ShellCommandLineGetValue(List, L"/Param2"), L"Val1")==0);\r
-    ASSERT(StrCmp(ShellCommandLineGetRawValue(List, 0), L"SimpleApplication")==0);\r
-\r
-    ShellCommandLineFreeVarList(List);\r
-  } else {\r
-    Print(L"param checking skipped.\r\n");\r
-  }\r
 \r
   // page break mode (done last so we can see the results)\r
   // we set this true at the begining of the program\r
@@ -333,4 +337,4 @@ done - ShellCommandLineFreeVarList
 done - ShellCommandLineGetFlag\r
 done - ShellCommandLineGetValue\r
 done - ShellCommandLineGetRawValue\r
-*/
\ No newline at end of file
+*/\r