static void Test_ExecTest_OutputStream() { using var outputStream = new MemoryStream(); var outputLength = Wsl.GetDefaultDistro().RunWslCommand("ls /dev | gzip -", outputStream); if (outputLength == 0) { throw new Exception("No output."); } outputStream.Seek(0L, SeekOrigin.Begin); using var gzStream = new GZipStream(outputStream, CompressionMode.Decompress, true); using var streamReader = new StreamReader(gzStream, new UTF8Encoding(false), false); var content = streamReader.ReadToEnd(); if (string.IsNullOrWhiteSpace(content)) { throw new Exception("No output."); } if (!content.Contains("null")) { throw new Exception("Invalid output."); } }
static void Test_GetDefaultDistro() { var defaultDistro = Wsl.GetDefaultDistro(); if (defaultDistro == null) { throw new Exception("Cannot find the default distro."); } }
static void Test_ExecTest() { var outputContent = Wsl.GetDefaultDistro().RunWslCommand("cat /etc/passwd"); if (outputContent == null) { throw new ArgumentNullException(nameof(outputContent)); } if (outputContent.Length == 0) { throw new Exception("No output."); } }