Skip to content

Commit cf6213e

Browse files
jeffhostetlerdscho
authored andcommitted
test-gvfs-prococol, t5799: tests for gvfs-helper
Create t/helper/test-gvfs-protocol.c and t/t5799-gvfs-helper.sh to test gvfs-helper. Create t/helper/test-gvfs-protocol.c as a stand-alone web server that speaks the GVFS Protocol [1] and serves loose objects and packfiles to clients. It is borrows heavily from the code in daemon.c. It includes a "mayhem" mode to cause various network and HTTP errors to test the retry/recovery ability of gvfs-helper. Create t/t5799-gvfs-helper.sh to test gvfs-helper. [1] https://github.com/microsoft/VFSForGit/blob/master/Protocol.md Signed-off-by: Jeff Hostetler <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent a527370 commit cf6213e

File tree

8 files changed

+2786
-7
lines changed

8 files changed

+2786
-7
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,6 +1700,7 @@ endif
17001700
BASIC_CFLAGS += $(CURL_CFLAGS)
17011701

17021702
PROGRAM_OBJS += gvfs-helper.o
1703+
TEST_PROGRAMS_NEED_X += test-gvfs-protocol
17031704

17041705
REMOTE_CURL_PRIMARY = git-remote-http$X
17051706
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X

bin-wrappers/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
/git-upload-pack
77
/scalar
88
/test-fake-ssh
9+
/test-gvfs-protocol
910
/test-tool

contrib/buildsystems/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,20 @@ set(wrapper_scripts
11251125
set(wrapper_test_scripts
11261126
test-fake-ssh test-tool)
11271127

1128+
if(CURL_FOUND)
1129+
list(APPEND wrapper_test_scripts test-gvfs-protocol)
1130+
1131+
add_executable(test-gvfs-protocol ${CMAKE_SOURCE_DIR}/t/helper/test-gvfs-protocol.c)
1132+
target_link_libraries(test-gvfs-protocol common-main)
1133+
1134+
if(MSVC)
1135+
set_target_properties(test-gvfs-protocol
1136+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)
1137+
set_target_properties(test-gvfs-protocol
1138+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)
1139+
endif()
1140+
endif()
1141+
11281142

11291143
foreach(script ${wrapper_scripts})
11301144
file(STRINGS ${CMAKE_SOURCE_DIR}/bin-wrappers/wrap-for-bin.sh content NEWLINE_CONSUME)

gvfs-helper.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,6 +1886,8 @@ static void install_loose(struct gh__request_params *params,
18861886
/*
18871887
* We expect a loose object when we do a GET -or- when we
18881888
* do a POST with only 1 object.
1889+
*
1890+
* Note that this content type is singular, not plural.
18891891
*/
18901892
if (strcmp(status->content_type.buf,
18911893
"application/x-git-loose-object")) {
@@ -2120,14 +2122,17 @@ static void do_throttle_spin(struct gh__request_params *params,
21202122
strbuf_addstr(&region, gh__server_type_label[params->server_type]);
21212123
trace2_region_enter("gvfs-helper", region.buf, NULL);
21222124

2123-
progress = start_progress(the_repository, progress_msg, duration);
2125+
if (gh__cmd_opts.show_progress)
2126+
progress = start_progress(the_repository, progress_msg, duration);
2127+
21242128
while (now < end) {
21252129
display_progress(progress, (now - begin));
21262130

21272131
sleep_millisec(100);
21282132

21292133
now = time(NULL);
21302134
}
2135+
21312136
display_progress(progress, duration);
21322137
stop_progress(&progress);
21332138

@@ -2696,13 +2701,15 @@ static void do__http_post__gvfs_objects(struct gh__response_status *status,
26962701
params.headers = curl_slist_append(params.headers,
26972702
"Content-Type: application/json");
26982703
/*
2699-
* We really always want a packfile. But if the payload only
2700-
* requests 1 OID, the server will send us a single loose
2701-
* objects instead. (Apparently the server ignores us when we
2702-
* only send application/x-git-packfile and does it anyway.)
2704+
* If our POST contains more than one object, we want the
2705+
* server to send us a packfile. We DO NOT want the non-standard
2706+
* concatenated loose object format, so we DO NOT send:
2707+
* "Accept: application/x-git-loose-objects" (plural)
27032708
*
2704-
* So to make it clear to my future self, go ahead and add
2705-
* an accept header for loose objects and own it.
2709+
* However, if the payload only requests 1 OID, the server
2710+
* will send us a single loose object instead of a packfile,
2711+
* so we ACK that and send:
2712+
* "Accept: application/x-git-loose-object" (singular)
27062713
*/
27072714
params.headers = curl_slist_append(params.headers,
27082715
"Accept: application/x-git-packfile");

t/helper/meson.build

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ test_tool = executable('test-tool',
8888
bin_wrappers += test_tool
8989
test_dependencies += test_tool
9090

91+
test_gvfs_protocol = executable('test-gvfs-protocol',
92+
sources: 'test-gvfs-protocol.c',
93+
dependencies: [libgit_commonmain],
94+
)
95+
bin_wrappers += test_gvfs_protocol
96+
test_dependencies += test_gvfs_protocol
97+
9198
test_fake_ssh = executable('test-fake-ssh',
9299
sources: 'test-fake-ssh.c',
93100
dependencies: [libgit_commonmain],

0 commit comments

Comments
 (0)