private static void fileDiff(String datafile, String testdir) throws Exception {
    String testFileDir = conf.get("test.data.files");

    // inbuilt assumption that the testdir has only one output file.
    Path diTest = new Path(tmppath, testdir);
    if (!fs.exists(diTest)) {
      throw new RuntimeException(TMPDIR + File.separator + testdir + " does not exist");
    }
    if (!ShimLoader.getHadoopShims().isDirectory(fs.getFileStatus(diTest))) {
      throw new RuntimeException(TMPDIR + File.separator + testdir + " is not a directory");
    }
    FSDataInputStream fiTest = fs.open((fs.listStatus(diTest))[0].getPath());

    FileInputStream fiGold = new FileInputStream(new File(testFileDir, datafile));
    if (!Utilities.contentsEqual(fiGold, fiTest, false)) {
      LOG.error(diTest.toString() + " does not match " + datafile);
      assertEquals(false, true);
    }
  }
Mimics the actual query compiler in generating end to end plans and testing
them out.
ql/src/test/org/apache/hadoop/hive/ql/exec/TestExecDriver.java