core/std: Fix race condition in os::mkdir_recursive tests

Added a change_dir_locked function to os, and use it in the
mkdir_recursive tests so that the tests don't clobber each other's
directory changes.
auto merge of #6144 : catamorphism/rust/mkdir_recursive-breakage, r=thestinger

r? @brson or @thestinger : Added a change_dir_locked function to os, and use it in the
mkdir_recursive tests so that the tests don't clobber each other's
directory changes.