func verifyFile(f *framework.Framework, pod *v1.Pod, fpath string, expectSize int64, ddInput string) error {
	ginkgo.By("verifying file size")
	rtnstr, err := utils.PodExec(f, pod, fmt.Sprintf("stat -c %%s %s", fpath))
	if err != nil || rtnstr == "" {
		return fmt.Errorf("unable to get file size via `stat %s`: %v", fpath, err)
	}
	size, err := strconv.Atoi(strings.TrimSuffix(rtnstr, "\n"))
	if err != nil {
		return fmt.Errorf("unable to convert string %q to int: %v", rtnstr, err)
	}
	if int64(size) != expectSize {
		return fmt.Errorf("size of file %s is %d, expected %d", fpath, size, expectSize)
	}

	ginkgo.By("verifying file hash")
	rtnstr, err = utils.PodExec(f, pod, fmt.Sprintf("md5sum %s | cut -d' ' -f1", fpath))
	if err != nil {
		return fmt.Errorf("unable to test file hash via `md5sum %s`: %v", fpath, err)
	}
	actualHash := strings.TrimSuffix(rtnstr, "\n")
	expectedHash, ok := md5hashes[expectSize]
	if !ok {
		return fmt.Errorf("File hash is unknown for file size %d. Was a new file size added to the test suite?",
			expectSize)
	}
	if actualHash != expectedHash {
		return fmt.Errorf("MD5 hash is incorrect for file %s with size %d. Expected: `%s`; Actual: `%s`",
			fpath, expectSize, expectedHash, actualHash)
	}

	return nil
}
// Verify that the test file is the expected size and contains the expected content.
Verify that the test file is the expected size and contains the expected content.
// Verify that the test file is the expected size and contains the expected content .
func verifyFile(f *framework.Framework, pod *v1.Pod, fpath string, expectSize int64, ddInput string) error {
	ginkgo.By("verifying file size")
	rtnstr, err := utils.PodExec(f, pod, fmt.Sprintf("stat -c %%s %s", fpath))
	if err != nil || rtnstr == "" {
		return fmt.Errorf("unable to get file size via `stat %s`: %v", fpath, err)
	}
	size, err := strconv.Atoi(strings.TrimSuffix(rtnstr, "\n"))
	if err != nil {
		return fmt.Errorf("unable to convert string %q to int: %v", rtnstr, err)
	}
	if int64(size) != expectSize {
		return fmt.Errorf("size of file %s is %d, expected %d", fpath, size, expectSize)
	}
	ginkgo.By("verifying file hash")
	rtnstr, err = utils.PodExec(f, pod, fmt.Sprintf("md5sum %s | cut -d' ' -f1", fpath))
	if err != nil {
		return fmt.Errorf("unable to test file hash via `md5sum %s`: %v", fpath, err)
	}
	actualHash := strings.TrimSuffix(rtnstr, "\n")
	expectedHash, ok := md5hashes[expectSize]
	if !ok {
		return fmt.Errorf("File hash is unknown for file size %d. Was a new file size added to the test suite?",
			expectSize)
	}
	if actualHash != expectedHash {
		return fmt.Errorf("MD5 hash is incorrect for file %s with size %d. Expected: `%s`; Actual: `%s`",
			fpath, expectSize, expectedHash, actualHash)
	}
	return nil
}
func verifyFile ( f * framework . Framework , pod * v1 . Pod , fpath string , expectSize int64 , ddInput string ) error { ginkgo . By ( " " ) rtnstr , err := utils . PodExec ( f , pod , fmt . Sprintf ( " " , fpath ) ) if err != nil || rtnstr == " " { return fmt . Errorf ( " " , fpath , err ) } size , err := strconv . Atoi ( strings . TrimSuffix ( rtnstr , " \n " ) ) if err != nil { return fmt . Errorf ( " " , rtnstr , err ) } if int64 ( size ) != expectSize { return fmt . Errorf ( " " , fpath , size , expectSize ) } ginkgo . By ( " " ) rtnstr , err = utils . PodExec ( f , pod , fmt . Sprintf ( " " , fpath ) ) if err != nil { return fmt . Errorf ( " " , fpath , err ) } actualHash := strings . TrimSuffix ( rtnstr , " \n " ) expectedHash , ok := md5hashes [ expectSize ] if ! ok { return fmt . Errorf ( " " , expectSize ) } if actualHash != expectedHash { return fmt . Errorf ( " " , fpath , expectSize , expectedHash , actualHash ) } return nil }
Verify that the test file is the expected size and contains the expected content.
Verify that the test file is the expected size and contains the expected content .