Ejemplo n.º 1
0
 /// <exception cref="System.IO.IOException"/>
 private void VerifyChecksum(string path, long checksum)
 {
     if (refIter == null)
     {
         refIter = refList.GetEnumerator();
     }
     if (printChecksum)
     {
         Log.Info("CRC info for reference file : " + path + " \t " + checksum);
     }
     else
     {
         if (!refIter.HasNext())
         {
             throw new IOException("Checking checksum for " + path + "Not enough elements in the refList"
                                   );
         }
         TestDFSUpgradeFromImage.ReferenceFileInfo info = refIter.Next();
         // The paths are expected to be listed in the same order
         // as they are traversed here.
         NUnit.Framework.Assert.AreEqual(info.path, path);
         NUnit.Framework.Assert.AreEqual("Checking checksum for " + path, info.checksum, checksum
                                         );
     }
 }
Ejemplo n.º 2
0
        /// <exception cref="System.IO.IOException"/>
        internal virtual void UnpackStorage(string tarFileName, string referenceName)
        {
            string tarFile = Runtime.GetProperty("test.cache.data", "build/test/cache") + "/"
                             + tarFileName;
            string   dataDir = Runtime.GetProperty("test.build.data", "build/test/data");
            FilePath dfsDir  = new FilePath(dataDir, "dfs");

            if (dfsDir.Exists() && !FileUtil.FullyDelete(dfsDir))
            {
                throw new IOException("Could not delete dfs directory '" + dfsDir + "'");
            }
            Log.Info("Unpacking " + tarFile);
            FileUtil.UnTar(new FilePath(tarFile), new FilePath(dataDir));
            //Now read the reference info
            BufferedReader reader = new BufferedReader(new FileReader(Runtime.GetProperty("test.cache.data"
                                                                                          , "build/test/cache") + "/" + referenceName));
            string line;

            while ((line = reader.ReadLine()) != null)
            {
                line = line.Trim();
                if (line.Length <= 0 || line.StartsWith("#"))
                {
                    continue;
                }
                string[] arr = line.Split("\\s+");
                if (arr.Length < 1)
                {
                    continue;
                }
                if (arr[0].Equals("printChecksums"))
                {
                    printChecksum = true;
                    break;
                }
                if (arr.Length < 2)
                {
                    continue;
                }
                TestDFSUpgradeFromImage.ReferenceFileInfo info = new TestDFSUpgradeFromImage.ReferenceFileInfo
                                                                     ();
                info.path     = arr[0];
                info.checksum = long.Parse(arr[1]);
                refList.AddItem(info);
            }
            reader.Close();
        }