aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-05-18 07:18:47 -0700
committerGravatar Craig Tiller <ctiller@google.com>2016-05-18 07:18:47 -0700
commitc5b7f36f4d7f93ad5e38a45c34e0b27b544c7507 (patch)
treee8600933d07f6fbee65bb55e6b0c8faf10ff1d44
parent4727b9be84aa3607a76bd8eca4588e82a4ffbec5 (diff)
Fix load file test
-rw-r--r--Makefile6
-rw-r--r--build.yaml1
-rw-r--r--test/core/support/load_file_test.c33
-rw-r--r--tools/run_tests/sources_and_headers.json3
-rw-r--r--vsprojects/buildtests_c.sln1
-rw-r--r--vsprojects/vcxproj/test/gpr_load_file_test/gpr_load_file_test.vcxproj3
6 files changed, 27 insertions, 20 deletions
diff --git a/Makefile b/Makefile
index 13df968e32..c0908c0698 100644
--- a/Makefile
+++ b/Makefile
@@ -7070,14 +7070,14 @@ else
-$(BINDIR)/$(CONFIG)/gpr_load_file_test: $(GPR_LOAD_FILE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(BINDIR)/$(CONFIG)/gpr_load_file_test: $(GPR_LOAD_FILE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
- $(Q) $(LD) $(LDFLAGS) $(GPR_LOAD_FILE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_load_file_test
+ $(Q) $(LD) $(LDFLAGS) $(GPR_LOAD_FILE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_load_file_test
endif
-$(OBJDIR)/$(CONFIG)/test/core/support/load_file_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/core/support/load_file_test.o: $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_gpr_load_file_test: $(GPR_LOAD_FILE_TEST_OBJS:.o=.dep)
diff --git a/build.yaml b/build.yaml
index e06c5ad419..c87641652f 100644
--- a/build.yaml
+++ b/build.yaml
@@ -1479,6 +1479,7 @@ targets:
src:
- test/core/support/load_file_test.c
deps:
+ - grpc
- gpr_test_util
- gpr
- name: gpr_log_test
diff --git a/test/core/support/load_file_test.c b/test/core/support/load_file_test.c
index 0125fd94fd..9874db3d9a 100644
--- a/test/core/support/load_file_test.c
+++ b/test/core/support/load_file_test.c
@@ -51,7 +51,7 @@ static void test_load_empty_file(void) {
FILE *tmp = NULL;
gpr_slice slice;
gpr_slice slice_with_null_term;
- int success;
+ grpc_error *error;
char *tmp_name;
LOG_TEST_NAME("test_load_empty_file");
@@ -61,12 +61,12 @@ static void test_load_empty_file(void) {
GPR_ASSERT(tmp != NULL);
fclose(tmp);
- slice = gpr_load_file(tmp_name, 0, &success);
- GPR_ASSERT(success == 1);
+ error = gpr_load_file(tmp_name, 0, &slice);
+ GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(GPR_SLICE_LENGTH(slice) == 0);
- slice_with_null_term = gpr_load_file(tmp_name, 1, &success);
- GPR_ASSERT(success == 1);
+ error = gpr_load_file(tmp_name, 1, &slice_with_null_term);
+ GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(GPR_SLICE_LENGTH(slice_with_null_term) == 1);
GPR_ASSERT(GPR_SLICE_START_PTR(slice_with_null_term)[0] == 0);
@@ -79,7 +79,7 @@ static void test_load_empty_file(void) {
static void test_load_failure(void) {
FILE *tmp = NULL;
gpr_slice slice;
- int success;
+ grpc_error *error;
char *tmp_name;
LOG_TEST_NAME("test_load_failure");
@@ -90,8 +90,9 @@ static void test_load_failure(void) {
fclose(tmp);
remove(tmp_name);
- slice = gpr_load_file(tmp_name, 0, &success);
- GPR_ASSERT(success == 0);
+ error = gpr_load_file(tmp_name, 0, &slice);
+ GPR_ASSERT(error != GRPC_ERROR_NONE);
+ GRPC_ERROR_UNREF(error);
GPR_ASSERT(GPR_SLICE_LENGTH(slice) == 0);
gpr_free(tmp_name);
gpr_slice_unref(slice);
@@ -101,7 +102,7 @@ static void test_load_small_file(void) {
FILE *tmp = NULL;
gpr_slice slice;
gpr_slice slice_with_null_term;
- int success;
+ grpc_error *error;
char *tmp_name;
const char *blah = "blah";
@@ -113,13 +114,13 @@ static void test_load_small_file(void) {
GPR_ASSERT(fwrite(blah, 1, strlen(blah), tmp) == strlen(blah));
fclose(tmp);
- slice = gpr_load_file(tmp_name, 0, &success);
- GPR_ASSERT(success == 1);
+ error = gpr_load_file(tmp_name, 0, &slice);
+ GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(GPR_SLICE_LENGTH(slice) == strlen(blah));
GPR_ASSERT(!memcmp(GPR_SLICE_START_PTR(slice), blah, strlen(blah)));
- slice_with_null_term = gpr_load_file(tmp_name, 1, &success);
- GPR_ASSERT(success == 1);
+ error = gpr_load_file(tmp_name, 1, &slice_with_null_term);
+ GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(GPR_SLICE_LENGTH(slice_with_null_term) == (strlen(blah) + 1));
GPR_ASSERT(strcmp((const char *)GPR_SLICE_START_PTR(slice_with_null_term),
blah) == 0);
@@ -133,7 +134,7 @@ static void test_load_small_file(void) {
static void test_load_big_file(void) {
FILE *tmp = NULL;
gpr_slice slice;
- int success;
+ grpc_error *error;
char *tmp_name;
static const size_t buffer_size = 124631;
unsigned char *buffer = gpr_malloc(buffer_size);
@@ -150,8 +151,8 @@ static void test_load_big_file(void) {
GPR_ASSERT(fwrite(buffer, 1, buffer_size, tmp) == buffer_size);
fclose(tmp);
- slice = gpr_load_file(tmp_name, 0, &success);
- GPR_ASSERT(success == 1);
+ error = gpr_load_file(tmp_name, 0, &slice);
+ GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(GPR_SLICE_LENGTH(slice) == buffer_size);
current = GPR_SLICE_START_PTR(slice);
for (i = 0; i < buffer_size; i++) {
diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json
index 325028dc00..85c5a37a51 100644
--- a/tools/run_tests/sources_and_headers.json
+++ b/tools/run_tests/sources_and_headers.json
@@ -539,7 +539,8 @@
{
"deps": [
"gpr",
- "gpr_test_util"
+ "gpr_test_util",
+ "grpc"
],
"headers": [],
"language": "c",
diff --git a/vsprojects/buildtests_c.sln b/vsprojects/buildtests_c.sln
index be8b5d40ac..95a7f17e52 100644
--- a/vsprojects/buildtests_c.sln
+++ b/vsprojects/buildtests_c.sln
@@ -394,6 +394,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpr_load_file_test", "vcxpr
lib = "False"
EndProjectSection
ProjectSection(ProjectDependencies) = postProject
+ {29D16885-7228-4C31-81ED-5F9187C7F2A9} = {29D16885-7228-4C31-81ED-5F9187C7F2A9}
{EAB0A629-17A9-44DB-B5FF-E91A721FE037} = {EAB0A629-17A9-44DB-B5FF-E91A721FE037}
{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}
EndProjectSection
diff --git a/vsprojects/vcxproj/test/gpr_load_file_test/gpr_load_file_test.vcxproj b/vsprojects/vcxproj/test/gpr_load_file_test/gpr_load_file_test.vcxproj
index 4182969f50..504ef8815c 100644
--- a/vsprojects/vcxproj/test/gpr_load_file_test/gpr_load_file_test.vcxproj
+++ b/vsprojects/vcxproj/test/gpr_load_file_test/gpr_load_file_test.vcxproj
@@ -162,6 +162,9 @@
</ClCompile>
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\grpc\grpc.vcxproj">
+ <Project>{29D16885-7228-4C31-81ED-5F9187C7F2A9}</Project>
+ </ProjectReference>
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\gpr_test_util\gpr_test_util.vcxproj">
<Project>{EAB0A629-17A9-44DB-B5FF-E91A721FE037}</Project>
</ProjectReference>