Bug 1060419 - make TestPipes.cpp use Printf.h, r=froydnj
authorTom Tromey <tom@tromey.com>
Fri, 09 Dec 2016 10:53:35 -1000
changeset 372571 90b1959687b2adc7f5db7d9ea1a388c92ae6cdff
parent 372570 bd0976eeda5fd26cb627a6c13e1e45bcadc6b9fb
child 372572 fee2788f109a4e898ddeaa74d63f5a877676afa4
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1060419
milestone54.0a1
Bug 1060419 - make TestPipes.cpp use Printf.h, r=froydnj MozReview-Commit-ID: LMFNBYVoJZf
xpcom/tests/gtest/TestPipes.cpp
--- a/xpcom/tests/gtest/TestPipes.cpp
+++ b/xpcom/tests/gtest/TestPipes.cpp
@@ -3,33 +3,33 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <algorithm>
 #include "gtest/gtest.h"
 #include "Helpers.h"
 #include "mozilla/ReentrantMonitor.h"
+#include "mozilla/Printf.h"
 #include "nsCOMPtr.h"
 #include "nsCRT.h"
 #include "nsIAsyncInputStream.h"
 #include "nsIAsyncOutputStream.h"
 #include "nsIBufferedStreams.h"
 #include "nsIClassInfo.h"
 #include "nsICloneableInputStream.h"
 #include "nsIInputStream.h"
 #include "nsIOutputStream.h"
 #include "nsIPipe.h"
 #include "nsISeekableStream.h"
 #include "nsIThread.h"
 #include "nsIRunnable.h"
 #include "nsStreamUtils.h"
 #include "nsString.h"
 #include "nsThreadUtils.h"
-#include "prprf.h"
 #include "prinrval.h"
 
 using namespace mozilla;
 
 #define ITERATIONS      33333
 char kTestPattern[] = "My hovercraft is full of eels.\n";
 
 bool gTrace = false;
@@ -109,27 +109,27 @@ TestPipe(nsIInputStream* in, nsIOutputSt
     nsCOMPtr<nsIThread> thread;
     rv = NS_NewNamedThread("TestPipe", getter_AddRefs(thread), receiver);
     if (NS_FAILED(rv)) return rv;
 
     uint32_t total = 0;
     PRIntervalTime start = PR_IntervalNow();
     for (uint32_t i = 0; i < ITERATIONS; i++) {
         uint32_t writeCount;
-        char *buf = PR_smprintf("%d %s", i, kTestPattern);
+        char *buf = mozilla::Smprintf("%d %s", i, kTestPattern);
         uint32_t len = strlen(buf);
         rv = WriteAll(out, buf, len, &writeCount);
         if (gTrace) {
             printf("wrote: ");
             for (uint32_t j = 0; j < writeCount; j++) {
                 putc(buf[j], stdout);
             }
             printf("\n");
         }
-        PR_smprintf_free(buf);
+        mozilla::SmprintfFree(buf);
         if (NS_FAILED(rv)) return rv;
         total += writeCount;
     }
     rv = out->Close();
     if (NS_FAILED(rv)) return rv;
 
     PRIntervalTime end = PR_IntervalNow();
 
@@ -227,28 +227,28 @@ TestShortWrites(nsIInputStream* in, nsIO
     nsCOMPtr<nsIThread> thread;
     rv = NS_NewNamedThread("TestShortWrites", getter_AddRefs(thread),
                            receiver);
     if (NS_FAILED(rv)) return rv;
 
     uint32_t total = 0;
     for (uint32_t i = 0; i < ITERATIONS; i++) {
         uint32_t writeCount;
-        char* buf = PR_smprintf("%d %s", i, kTestPattern);
+        char* buf = mozilla::Smprintf("%d %s", i, kTestPattern);
         uint32_t len = strlen(buf);
         len = len * rand() / RAND_MAX;
         len = std::min(1u, len);
         rv = WriteAll(out, buf, len, &writeCount);
         if (NS_FAILED(rv)) return rv;
         EXPECT_EQ(writeCount, len);
         total += writeCount;
 
         if (gTrace)
             printf("wrote %d bytes: %s\n", writeCount, buf);
-        PR_smprintf_free(buf);
+        mozilla::SmprintfFree(buf);
         //printf("calling Flush\n");
         out->Flush();
         //printf("calling WaitForReceipt\n");
 
 #ifdef DEBUG
         const uint32_t received =
           receiver->WaitForReceipt(writeCount);
         EXPECT_EQ(received, writeCount);
@@ -340,29 +340,29 @@ TEST(Pipes, ChainedPipes)
     nsCOMPtr<nsIThread> receiverThread;
     rv = NS_NewNamedThread("ChainedPipeRecv", getter_AddRefs(receiverThread),
                            receiver);
     if (NS_FAILED(rv)) return;
 
     uint32_t total = 0;
     for (uint32_t i = 0; i < ITERATIONS; i++) {
         uint32_t writeCount;
-        char* buf = PR_smprintf("%d %s", i, kTestPattern);
+        char* buf = mozilla::Smprintf("%d %s", i, kTestPattern);
         uint32_t len = strlen(buf);
         len = len * rand() / RAND_MAX;
         len = std::max(1u, len);
         rv = WriteAll(out1, buf, len, &writeCount);
         if (NS_FAILED(rv)) return;
         EXPECT_EQ(writeCount, len);
         total += writeCount;
 
         if (gTrace)
             printf("wrote %d bytes: %s\n", writeCount, buf);
 
-        PR_smprintf_free(buf);
+        mozilla::SmprintfFree(buf);
     }
     if (gTrace) {
         printf("wrote total of %d bytes\n", total);
     }
     rv = out1->Close();
     if (NS_FAILED(rv)) return;
 
     thread->Shutdown();