Exemple #1
0
        private void FinishMediaTesterRun()
        {
            _mediaTesterThread = null;
            _mediaTester       = null;

            EnableControls();
        }
Exemple #2
0
 private void OnMediaTesterException(MediaTester mediaTester, Exception exception)
 {
     WriteLog(mediaTester, $"{exception.Message}");
     if (exception.InnerException != null)
     {
         OnMediaTesterException(mediaTester, exception.InnerException);
     }
 }
Exemple #3
0
 private static void AfterWriteBlock(MediaTester mediaTester, long absoluteDataBlockIndex, long absoluteDataByteIndex, string testFilePath, long writeBytesPerSecond, int bytesWritten, int bytesFailedWrite)
 {
     if (bytesFailedWrite == 0)
     {
         WriteLog(mediaTester, $"Successfully wrote block {absoluteDataBlockIndex.ToString("#,##0")}. Byte index: {absoluteDataByteIndex.ToString("#,##0")} / {mediaTester.Options.TotalBytesToTest.ToString("#,##0")}. {writeBytesPerSecond.ToString("#,##0")} B/sec ({mediaTester.ProgressPercent.ToString("0.00")}%)");
     }
     else
     {
         WriteLog(mediaTester, $"FAILED writing block {absoluteDataBlockIndex.ToString("#,##0")}. Byte index: {absoluteDataByteIndex.ToString("#,##0")} / {mediaTester.Options.TotalBytesToTest.ToString("#,##0")}. ({mediaTester.ProgressPercent.ToString("0.00")}%)");
     }
 }
Exemple #4
0
 private static void AfterVerifyBlock(MediaTester mediaTester, long absoluteDataBlockIndex, long absoluteDataByteIndex, string testFilePathlong, long readBytesPerSecond, int bytesVerified, int bytesFailed, bool isQuickTest = false)
 {
     if (bytesFailed == 0)
     {
         WriteLog(mediaTester, $"Verified {(isQuickTest ? "quick test " : string.Empty)}block {absoluteDataBlockIndex.ToString("#,##0")}. Byte index: {absoluteDataByteIndex.ToString("#,##0")} / {mediaTester.Options.TotalBytesToTest.ToString("#,##0")}. {(isQuickTest ? string.Empty : readBytesPerSecond.ToString("#,##0") + "B/sec ")}({mediaTester.ProgressPercent.ToString("0.00")}%)");
     }
     else
     {
         WriteLog(mediaTester, $"FAILED {(isQuickTest ? "quick test " : string.Empty)}block {absoluteDataBlockIndex.ToString("#,##0")}! Byte index: {absoluteDataByteIndex.ToString("#,##0")} / {mediaTester.Options.TotalBytesToTest.ToString("#,##0")}. {(isQuickTest ? string.Empty : readBytesPerSecond.ToString("#,##0") + "B/sec ")}({mediaTester.ProgressPercent.ToString("0.00")}%)");
     }
 }
Exemple #5
0
 private void AfterWriteBlock(MediaTester mediaTester, long absoluteDataBlockIndex, long absoluteDataByteIndex, string testFilePath, long writeBytesPerSecond, int bytesWritten, int bytesFailedWrite)
 {
     UpdateStatus(writeBytesPerSecond: writeBytesPerSecond);
     if (bytesFailedWrite == 0)
     {
         //WriteLog(mediaTester, $"Successfully wrote block {absoluteDataBlockIndex.ToString("#,##0")}. Byte index: {absoluteDataByteIndex.ToString("#,##0")}.");
     }
     else
     {
         WriteLog(mediaTester, $"FAILED writing block {absoluteDataBlockIndex.ToString("#,##0")}. Byte index: {absoluteDataByteIndex.ToString("#,##0")}.");
     }
 }
Exemple #6
0
        private void InitializeMediaTester()
        {
            UpdateOptionsFromUi();
            _mediaTester                   = new MediaTester(_mediaTesterOptions);
            _mediaTester.OnException      += OnMediaTesterException;
            _mediaTester.AfterQuickTest   += AfterQuickTest;
            _mediaTester.AfterVerifyBlock += AfterVerifyBlock;
            _mediaTester.AfterWriteBlock  += AfterWriteBlock;

            ClearLog(null, null);
            WriteLog(_mediaTester, $"Test data path: '{_mediaTester.GetTestDirectory()}'...");
        }
Exemple #7
0
        private void WriteLog(MediaTester mediaTester, string message)
        {
            if (ActivityLogTextBox.InvokeRequired)
            {
                WriteLogDelegate d = new WriteLogDelegate(WriteLog);
                this.Invoke(d, new object[] { mediaTester, message });
                return;
            }

            if (message == null)
            {
                ActivityLogTextBox.Text = string.Empty;
            }
            else
            {
                ActivityLogTextBox.AppendText((ActivityLogTextBox.Text.Length == 0 ? string.Empty : "\r\n") + message);
            }
        }
Exemple #8
0
        private void AfterVerifyBlock(MediaTester mediaTester, long absoluteDataBlockIndex, long absoluteDataByteIndex, string testFilePath, long readBytesPerSecond, int bytesVerified, int bytesFailed, bool isQuickTest = false)
        {
            if (!isQuickTest)
            {
                UpdateStatus(readBytesPerSecond: readBytesPerSecond);
            }

            if (bytesFailed == 0)
            {
                if (isQuickTest)
                {
                    WriteLog(mediaTester, $"{(isQuickTest ? "Quick test: " : string.Empty)}Verified block {absoluteDataBlockIndex.ToString("#,##0")}. Byte index: {absoluteDataByteIndex.ToString("#,##0")}");
                }
            }
            else
            {
                WriteLog(mediaTester, $"{(isQuickTest ? "Quick test: " : string.Empty)}FAILED block {absoluteDataBlockIndex.ToString("#,##0")}! Byte index: {absoluteDataByteIndex.ToString("#,##0")}");
            }
        }
Exemple #9
0
        private void UpdateTargetInformation()
        {
            string targetTotalBytes     = PALCEHOLDER_VALUE;
            string targetAvailableBytes = PALCEHOLDER_VALUE;
            string targetDirectory      = TargetTextBox.Text;

            if (!string.IsNullOrWhiteSpace(targetDirectory))
            {
                if (Directory.Exists(targetDirectory))
                {
                    long lTargetTotalBytes;
                    long lTargetAvailableBytes = MediaTester.GetAvailableBytes(targetDirectory, out lTargetTotalBytes);
                    targetTotalBytes     = $"{lTargetTotalBytes.ToString("#,##0")}{BYTES}";
                    targetAvailableBytes = $"{lTargetAvailableBytes.ToString("#,##0")}{BYTES}";
                }
            }

            TargetTotalBytesLabel.Text     = targetTotalBytes;
            TargetAvailableBytesLabel.Text = targetAvailableBytes;
        }
Exemple #10
0
 private void AfterQuickTest(MediaTester mediaTester, long absoluteDataBlockIndex, long absoluteDataByteIndex, string testFilePath, long readBytesPerSecond, int bytesVerified, int bytesFailed)
 {
     AfterVerifyBlock(mediaTester, absoluteDataBlockIndex, absoluteDataByteIndex, testFilePath, readBytesPerSecond, bytesVerified, bytesFailed, true);
 }
Exemple #11
0
        static void Main(string[] args)
        {
            string testDirectory = null;

            if (args == null || args.Length < 1)
            {
                while (string.IsNullOrEmpty(testDirectory))
                {
                    Console.WriteLine();
                    Console.WriteLine();
                    Console.Write("Please enter a drive letter or path to test: ");
                    testDirectory = Console.ReadLine();
                }
                if (!testDirectory.Contains(@":\"))
                {
                    testDirectory = Path.Combine(testDirectory.Substring(0, 1).ToUpper() + @":\", MediaTester.TempSubDirectoryName);
                }
            }
            else
            {
                testDirectory = args[0];
            }

            testDirectory = testDirectory.TrimEnd('\\');
            if (!testDirectory.EndsWith(MediaTester.TempSubDirectoryName))
            {
                testDirectory = Path.Combine(testDirectory, MediaTester.TempSubDirectoryName);
            }

            Console.WriteLine();
            Console.WriteLine($"Bytes per file: {MediaTester.FILE_SIZE.ToString("#,##0")}");
            Console.WriteLine($"Data block size: {MediaTester.DATA_BLOCK_SIZE.ToString("#,##0")}");
            Console.WriteLine($"Blocks per file: {MediaTester.DATA_BLOCKS_PER_FILE.ToString("#,##0")}");
            Console.WriteLine($"Writing temp files to: {testDirectory}...");
            Console.WriteLine();

            var mediaTester = new MediaTester(testDirectory)
            {
            };

            mediaTester.AfterWriteBlock  += AfterWriteBlock;
            mediaTester.AfterQuickTest   += AfterQuickTest;
            mediaTester.AfterVerifyBlock += AfterVerifyBlock;
            mediaTester.OnException      += OnMediaTesterException;

            bool result = mediaTester.FullTest();

            Console.WriteLine();
            Console.WriteLine("Media Test Summary...");
            Console.WriteLine("------------------------------------------------");
            Console.WriteLine("Result: " + (result ? "PASS" : "FAIL"));
            Console.WriteLine($"Temp File Path: {mediaTester.Options.TestDirectory}");
            Console.WriteLine($"Total bytes attempted: {mediaTester.Options.TotalBytesToTest.ToString("#,##0")}");

            if (!mediaTester.Options.StopProcessingOnFailure || mediaTester.TotalBytesVerified > 0)
            {
                Console.WriteLine($"Verified bytes: {mediaTester.TotalBytesVerified.ToString("#,##0")}");
            }

            if (!mediaTester.Options.StopProcessingOnFailure || mediaTester.TotalBytesFailed > 0)
            {
                Console.WriteLine($"Failed bytes: {mediaTester.TotalBytesFailed.ToString("#,##0")}");
            }

            if (mediaTester.FirstFailingByteIndex > 0)
            {
                Console.WriteLine($"First failing byte index: {mediaTester.FirstFailingByteIndex.ToString("#,##0")}{(mediaTester.Options.QuickFirstFailingByteMethod ? " (quick method)" : string.Empty)}");
            }

            if (!result)
            {
                Console.WriteLine();
                for (int i = 0; i < 20; i++)
                {
                    Console.Write(i % 2 == 0 ? string.Empty : "   ");
                    for (int j = 0; j < 15; j++)
                    {
                        Console.Write("FAIL!  ");
                    }
                    Console.WriteLine();
                }
            }

            Console.WriteLine();
            Console.WriteLine("Press enter to continue...");
            Console.ReadLine();
        }
Exemple #12
0
        private static void WriteLog(MediaTester mediaTester, string message)
        {
            string finalMessage = (mediaTester.IsSuccess ? "No errors" : "FAILURES!") + " - " + message;

            Console.WriteLine(finalMessage);
        }
Exemple #13
0
 private static void AfterVerifyBlock(MediaTester mediaTester, long absoluteDataBlockIndex, long absoluteDataByteIndex, string testFilePath, long readBytesPerSecond, int bytesVerified, int bytesFailed, long verifyBytesPerSecond)
 {
     AfterVerifyBlock(mediaTester, absoluteDataBlockIndex, absoluteDataByteIndex, testFilePath, readBytesPerSecond, bytesVerified, bytesFailed, verifyBytesPerSecond, false);
 }