VirtualBox

Changeset 83336 in vbox


Ignore:
Timestamp:
Mar 19, 2020 4:44:56 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
136532
Message:

Guest Control/Main + Validation Kit: More bugfixing for the "copy_to" testcases, enabled more (before known-to-be-buggy) tests. bugref:9320

Location:
trunk/src/VBox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/GuestSessionImplTasks.h

    r82968 r83336  
    4747        : enmType(FsObjType_Unknown)
    4848        , enmPathStyle(PathStyle_Unknown)
    49         , fDryRun(false) { } /** @todo r=bird: only half initialized. See comments in GuestSession::fileCopyToGuest(). */
    50 
     49        , fDryRun(false) { RT_ZERO(Type); }
     50
     51    /** The (absolute) path to the source to use. */
    5152    Utf8Str     strSource;
     53    /** Filter to use. Currently not implemented and thus ignored. */
    5254    Utf8Str     strFilter;
     55    /** The object type of this source. */
    5356    FsObjType_T enmType;
     57    /** The path style to use. */
    5458    PathStyle_T enmPathStyle;
     59    /** Whether to do a dry run (e.g. not really touching anything) or not. */
    5560    bool        fDryRun;
     61    /** Union to keep type-specific data. Must be a POD type (zero'ing). */
    5662    union
    5763    {
     
    6167            /** Directory copy flags. */
    6268            DirectoryCopyFlag_T fCopyFlags;
     69            /** Whether to follow symbolic links or not. */
    6370            bool                fFollowSymlinks; /** @todo Remove once we have that parameter in DirectoryCopyFlag_T. */
     71            /** Whether to copy the directory recursively or not. */
    6472            bool                fRecursive;
    6573        } Dir;
     
    6977            /** File copy flags. */
    7078            FileCopyFlag_T      fCopyFlags;
     79            /** Source file offset to start copying from. */
     80            size_t              offStart;
    7181            /** Host file handle to use for reading from / writing to.
    7282             *  Optional and can be NULL if not used. */
    7383            PRTFILE             phFile;
    74             /** Source file offset to start copying from. */
    75             size_t              offStart;
    7684            /** Source size (in bytes) to copy. */
    7785            uint64_t            cbSize;
  • trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp

    r83323 r83336  
    30373037    GuestSessionFsSourceSet SourceSet;
    30383038
    3039     /** @todo r=bird: The GuestSessionFsSourceSpec constructor does not zero the
    3040      *        members you aren't setting here and there are no hints about "input"
    3041      *        vs "task" members, so you have me worrying about using random stack by
    3042      *        accident somewhere...  For instance Type.File.phFile sure sounds like
    3043      *        an input field and thus a disaster waiting to happen. */
    30443039    GuestSessionFsSourceSpec source;
    30453040    source.strSource            = aSource;
  • trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp

    r83335 r83336  
    247247 * Creates a directory on the guest.
    248248 *
    249  * @return VBox status code. VERR_ALREADY_EXISTS if directory on the guest already exists.
     249 * @return VBox status code.
     250 *         VINF_ALREADY_EXISTS if directory on the guest already exists (\a fCanExist is \c true).
     251 *         VWRN_ALREADY_EXISTS if directory on the guest already exists but must not exist (\a fCanExist is \c false).
    250252 * @param  strPath                  Absolute path to directory on the guest (guest style path) to create.
    251253 * @param  enmDirectoryCreateFlags  Directory creation flags.
     
    270272            setProgressErrorMsg(VBOX_E_IPRT_ERROR,
    271273                                Utf8StrFmt(GuestSession::tr("Guest directory \"%s\" already exists"), strPath.c_str()));
    272             return VERR_ALREADY_EXISTS;
    273         }
     274            rc = VERR_ALREADY_EXISTS;
     275        }
     276        else
     277            rc = VWRN_ALREADY_EXISTS;
    274278    }
    275279    else
     
    282286                {
    283287                    case VERR_FILE_NOT_FOUND:
     288                        RT_FALL_THROUGH();
    284289                    case VERR_PATH_NOT_FOUND:
    285290                        rc = mSession->i_directoryCreate(strPath.c_str(), fMode, enmDirectoryCreateFlags, &rcGuest);
     
    288293                        break;
    289294                }
     295
     296                if (RT_FAILURE(rc))
     297                    setProgressErrorMsg(VBOX_E_IPRT_ERROR,
     298                                        Utf8StrFmt(GuestSession::tr("Guest error creating directory \"%s\" on the guest: %Rrc"),
     299                                                   strPath.c_str(), rcGuest));
    290300                break;
    291301            }
    292302
    293303            default:
     304                setProgressErrorMsg(VBOX_E_IPRT_ERROR,
     305                                    Utf8StrFmt(GuestSession::tr("Host error creating directory \"%s\" on the guest: %Rrc"),
     306                                               strPath.c_str(), rc));
    294307                break;
    295308        }
    296     }
    297 
    298     if (RT_FAILURE(rc))
    299     {
    300         if (rc == VERR_GSTCTL_GUEST_ERROR)
    301         {
    302             setProgressErrorMsg(VBOX_E_IPRT_ERROR, GuestProcess::i_guestErrorToString(rcGuest));
    303         }
    304         else
    305             setProgressErrorMsg(VBOX_E_IPRT_ERROR,
    306                                 Utf8StrFmt(GuestSession::tr("Error creating directory on the guest: %Rrc"), strPath.c_str(), rc));
    307309    }
    308310
     
    779781 *
    780782 * @return VBox status code. VINF_NO_CHANGE if file was skipped.
    781  * @param  strSource            Full path of source file on the host to copy.
    782  * @param  strDest              Full destination path and file name (guest style) to copy file to.
     783 * @param  strSrc               Full path of source file on the host to copy.
     784 * @param  strDst               Full destination path and file name (guest style) to copy file to.
    783785 * @param  fFileCopyFlags       File copy flags.
    784786 */
    785 int GuestSessionTask::fileCopyToGuest(const Utf8Str &strSource, const Utf8Str &strDest, FileCopyFlag_T fFileCopyFlags)
    786 {
    787     LogFlowThisFunc(("strSource=%s, strDest=%s, fFileCopyFlags=0x%x\n", strSource.c_str(), strDest.c_str(), fFileCopyFlags));
    788 
    789     Utf8Str strDestFinal = strDest;
    790 
    791     /** @todo r=bird: Why do we need to do this here?  It's a waste of time (extra
    792      *        IPC) for 99% of the calls, it only does something useful if the
    793      *        destination is a directory, and you should be able to handle that just
    794      *        as efficiently in the i_fileOpen() failure path. */
    795     GuestFsObjData dstObjData;
    796     int rcGuest = VERR_IPE_UNINITIALIZED_STATUS;
    797     int rc = mSession->i_fsQueryInfo(strDest, TRUE /* fFollowSymlinks */, dstObjData, &rcGuest);
    798     if (rc == VERR_GSTCTL_GUEST_ERROR && rcGuest == VERR_FILE_NOT_FOUND) /* File might not exist on the guest yet. */
    799         rc = VINF_SUCCESS;
    800     else if (RT_FAILURE(rc))
    801     {
    802         setProgressErrorMsg(VBOX_E_IPRT_ERROR, rc == VERR_GSTCTL_GUEST_ERROR ? rcGuest : rc,
    803                             GuestSession::tr("Destination file lookup for \"%s\" failed: %Rrc"),
    804                             strDest.c_str(), rc == VERR_GSTCTL_GUEST_ERROR ? rcGuest : rc);
    805         return rc;
    806     }
    807     else
    808     {
    809         switch (dstObjData.mType)
    810         {
    811             case FsObjType_Directory:
    812             {
    813                 /* Build the final file name with destination path (on the host). */
    814                 char szDstPath[RTPATH_MAX];
    815                 /** @todo r=bird: WTF IS THIS SUPPOSED TO BE?!? Use RTStrCopy, memcpy, or similar!
    816                  * Ever thought about modifying strDestFinal (it's 'Dst' not 'Dest' btw.)
    817                  * directly?  There are any number of append and insert methods in the
    818                  * RTCString/Utf8Str class for doing that! */
    819                 RTStrPrintf2(szDstPath, sizeof(szDstPath), "%s", strDest.c_str());
    820 
    821                 /** @todo r=bird: You're totally ignoring the guest slash-style here! Callers
    822                  *        should have this info. */
    823                 /** @todo r=bird: This is wrong even on windows if strDest is 'C:' and the
    824                  *        current working directory (CWD) isn't the root of the drive. :-) */
    825                 if (   !strDest.endsWith("\\")
    826                     && !strDest.endsWith("/"))
    827                     RTStrCat(szDstPath, sizeof(szDstPath), "/");
    828 
    829                 RTStrCat(szDstPath, sizeof(szDstPath), RTPathFilename(strSource.c_str()));
    830 
    831                 strDestFinal = szDstPath;
    832                 break;
    833             }
    834 
    835             case FsObjType_File:
    836                 if (fFileCopyFlags & FileCopyFlag_NoReplace)
    837                 {
    838                     setProgressErrorMsg(VBOX_E_IPRT_ERROR,
    839                                         Utf8StrFmt(GuestSession::tr("Destination file \"%s\" already exists"),
    840                                                    strDest.c_str(), rc));
    841                     rc = VERR_ALREADY_EXISTS;
    842                 }
    843                 break;
    844 
    845             /** @todo r=brent,r=bird: you follow symlinks, so this cannot happen at present.
    846              *        That said, maybe it isn't intentional to always follow symlinks? */
    847             case FsObjType_Symlink:
    848                  if (!(fFileCopyFlags & FileCopyFlag_FollowLinks))
    849                 {
    850                     setProgressErrorMsg(VBOX_E_IPRT_ERROR,
    851                                         Utf8StrFmt(GuestSession::tr("Destination file \"%s\" is a symbolic link"),
    852                                                    strDest.c_str(), rc));
    853                     rc = VERR_IS_A_SYMLINK;
    854                 }
    855                 break;
    856 
    857             default:
    858                 setProgressErrorMsg(VBOX_E_IPRT_ERROR,
    859                                     Utf8StrFmt(GuestSession::tr("Destination element \"%s\" not supported"), strDest.c_str()));
    860                 rc = VERR_NOT_SUPPORTED;
    861                 break;
    862         }
    863     }
    864 
    865     if (RT_FAILURE(rc))
    866         return rc;
     787int GuestSessionTask::fileCopyToGuest(const Utf8Str &strSrc, const Utf8Str &strDst, FileCopyFlag_T fFileCopyFlags)
     788{
     789    LogFlowThisFunc(("strSource=%s, strDst=%s, fFileCopyFlags=0x%x\n", strSrc.c_str(), strDst.c_str(), fFileCopyFlags));
     790
     791    Utf8Str strDstFinal = strDst;
    867792
    868793    GuestFileOpenInfo dstOpenInfo;
    869     dstOpenInfo.mFilename        = strDestFinal;
     794    dstOpenInfo.mFilename        = strDstFinal;
    870795    if (fFileCopyFlags & FileCopyFlag_NoReplace)
    871796        dstOpenInfo.mOpenAction  = FileOpenAction_CreateNew;
     
    876801
    877802    ComObjPtr<GuestFile> dstFile;
    878     rc = mSession->i_fileOpen(dstOpenInfo, dstFile, &rcGuest);
     803    int rcGuest;
     804    int rc = mSession->i_fileOpen(dstOpenInfo, dstFile, &rcGuest);
    879805    if (RT_FAILURE(rc))
    880806    {
    881807        setProgressErrorMsg(VBOX_E_IPRT_ERROR, rc == VERR_GSTCTL_GUEST_ERROR ? rcGuest : rc,
    882808                            GuestSession::tr("Destination file \"%s\" could not be opened: %Rrc"),
    883                             strDestFinal.c_str(), rc == VERR_GSTCTL_GUEST_ERROR ? rcGuest : rc);
     809                            strDstFinal.c_str(), rc == VERR_GSTCTL_GUEST_ERROR ? rcGuest : rc);
    884810        return rc;
    885811    }
     
    894820    if (RT_SUCCESS(rc))
    895821    {
    896         rc = RTPathReal(strSource.c_str(), szSrcReal, sizeof(szSrcReal));
     822        rc = RTPathReal(strSrc.c_str(), szSrcReal, sizeof(szSrcReal));
    897823        if (RT_FAILURE(rc))
    898824        {
    899825            setProgressErrorMsg(VBOX_E_IPRT_ERROR,
    900826                                Utf8StrFmt(GuestSession::tr("Source path lookup for \"%s\" failed: %Rrc"),
    901                                            strSource.c_str(), rc));
     827                                           strSrc.c_str(), rc));
    902828        }
    903829        else
     
    908834                if (fFileCopyFlags & FileCopyFlag_Update)
    909835                {
    910                     RTTIMESPEC dstModificationTimeTS;
    911                     RTTimeSpecSetSeconds(&dstModificationTimeTS, dstObjData.mModificationTime);
    912                     if (RTTimeSpecCompare(&dstModificationTimeTS, &srcObjInfo.ModificationTime) <= 0)
     836                    GuestFsObjData dstObjData;
     837                    rc = mSession->i_fileQueryInfo(strDstFinal, fFileCopyFlags & FileCopyFlag_FollowLinks, dstObjData, &rcGuest);
     838                    if (RT_SUCCESS(rc))
    913839                    {
    914                         setProgressErrorMsg(VBOX_E_IPRT_ERROR,
    915                                             Utf8StrFmt(GuestSession::tr("Destination file \"%s\" has same or newer modification date"),
    916                                                        strDestFinal.c_str()));
    917                         fSkip = true;
     840                        RTTIMESPEC dstModificationTimeTS;
     841                        RTTimeSpecSetSeconds(&dstModificationTimeTS, dstObjData.mModificationTime);
     842                        if (RTTimeSpecCompare(&dstModificationTimeTS, &srcObjInfo.ModificationTime) <= 0)
     843                        {
     844                            LogRel2(("Guest Control: Destination file \"%s\" has same or newer modification date, skipping",
     845                                     strDstFinal.c_str()));
     846                            fSkip = true;
     847                        }
     848                    }
     849                    else
     850                    {
     851                        if (rc == VERR_GSTCTL_GUEST_ERROR)
     852                        {
     853                            switch (rcGuest)
     854                            {
     855                                case VERR_FILE_NOT_FOUND:
     856                                    rc = VINF_SUCCESS;
     857                                    break;
     858
     859                                default:
     860                                    setProgressErrorMsg(VBOX_E_IPRT_ERROR,
     861                                                        Utf8StrFmt(GuestSession::tr("Guest error while determining object data for guest file \"%s\": %Rrc"),
     862                                                           strDstFinal.c_str(), rcGuest));
     863                                    break;
     864                            }
     865                        }
     866                        else
     867                            setProgressErrorMsg(VBOX_E_IPRT_ERROR,
     868                                                Utf8StrFmt(GuestSession::tr("Host error while determining object data for guest file \"%s\": %Rrc"),
     869                                                           strDstFinal.c_str(), rc));
    918870                    }
    919871                }
     
    942894        {
    943895            LogFlowThisFunc(("Copying '%s' to '%s' (%RI64 bytes) ...\n",
    944                              szSrcReal, strDestFinal.c_str(), srcObjInfo.cbObject));
     896                             szSrcReal, strDstFinal.c_str(), srcObjInfo.cbObject));
    945897
    946898            rc = fileCopyToGuestInner(hSrcFile, dstFile, fFileCopyFlags, 0 /* Offset, unused */, srcObjInfo.cbObject);
     
    10501002    if (mSourceSpec.enmType == FsObjType_Directory)
    10511003    {
     1004        LogFlowFunc(("Directory: mSrcRootAbs=%s, mDstRootAbs=%s, fCopyFlags=%#x, fFollowSymlinks=%RTbool, fRecursive=%RTbool\n",
     1005                     mSrcRootAbs.c_str(), mDstRootAbs.c_str(), mSourceSpec.Type.Dir.fCopyFlags,
     1006                     mSourceSpec.Type.Dir.fFollowSymlinks, mSourceSpec.Type.Dir.fRecursive));
     1007
    10521008        if (   !mSrcRootAbs.endsWith("/")
    10531009            && !mSrcRootAbs.endsWith("\\"))
     
    10581014            mDstRootAbs += "/";
    10591015    }
     1016    else if (mSourceSpec.enmType == FsObjType_File)
     1017    {
     1018        LogFlowFunc(("File: mSrcRootAbs=%s, mDstRootAbs=%s, fCopyFlags=%#x\n",
     1019                     mSrcRootAbs.c_str(), mDstRootAbs.c_str(), mSourceSpec.Type.File.fCopyFlags));
     1020    }
     1021    else
     1022        AssertFailedReturn(VERR_NOT_IMPLEMENTED);
    10601023
    10611024    return VINF_SUCCESS;
     
    14581421                && !strSrc.endsWith("\\"))
    14591422            {
    1460                 /** @todo r=bird: All hosts aren't windows either, use RTPATH_IS_SLASH() here! */
    1461                 if (   !strDst.endsWith("/")
    1462                     && !strDst.endsWith("\\"))
     1423                if (!RTPATH_IS_SLASH(strDst[strDst.length() - 1]))
    14631424                    strDst += "/";
    14641425
    1465                 /** @todo r=bird: Very unnecessary to use Utf8StrFmt(%s) here when Utf8Str()
    1466                  *        would do perfectly.  Also missing try catch. */
    1467                 strDst += Utf8StrFmt("%s", RTPathFilenameEx(strSrc.c_str(), mfPathStyle));
     1426                strDst += Utf8Str(RTPathFilenameEx(strSrc.c_str(), mfPathStyle));
    14681427            }
    14691428
     
    17001659        Utf8Str strDst = mDest;
    17011660
    1702         if (itSrc->enmType == FsObjType_Directory)
    1703         {
    1704             /* If the source does not end with a slash, copy over the entire directory
    1705              * (and not just its contents). */
    1706             if (   !strSrc.endsWith("/")
    1707                 && !strSrc.endsWith("\\"))
    1708             {
    1709                 if (   !strDst.endsWith("/")
    1710                     && !strDst.endsWith("\\"))
    1711                     strDst += "/";
    1712 
    1713                 strDst += Utf8StrFmt("%s", RTPathFilenameEx(strSrc.c_str(), mfPathStyle));
    1714             }
    1715         }
    1716 
    1717         LogFlowFunc(("strSrc=%s, strDst=%s\n", strSrc.c_str(), strDst.c_str()));
     1661        LogFlowFunc(("Source: strSrc=%s, strDst=%s\n", strSrc.c_str(), strDst.c_str()));
    17181662
    17191663        RTFSOBJINFO srcFsObjInfo;
     
    18181762        AssertPtr(pList);
    18191763
     1764        Utf8Str strSrcRootAbs = pList->mSrcRootAbs;
     1765        Utf8Str strDstRootAbs = pList->mDstRootAbs;
     1766
    18201767        bool     fCopyIntoExisting = false;
    18211768        bool     fFollowSymlinks   = false;
    18221769        uint32_t fDirMode          = 0700; /** @todo Play safe by default; implement ACLs. */
    18231770
    1824         LogFlowFunc(("List: srcRootAbs=%s, dstRootAbs=%s\n", pList->mSrcRootAbs.c_str(), pList->mDstRootAbs.c_str()));
     1771        GuestFsObjData dstObjData;
     1772        int rcGuest;
     1773        rc = mSession->i_fsQueryInfo(strDstRootAbs, pList->mSourceSpec.Type.Dir.fFollowSymlinks, dstObjData, &rcGuest);
     1774        if (RT_FAILURE(rc))
     1775        {
     1776            if (rc == VERR_GSTCTL_GUEST_ERROR)
     1777            {
     1778                switch (rcGuest)
     1779                {
     1780                    case VERR_PATH_NOT_FOUND:
     1781                        RT_FALL_THROUGH();
     1782                    case VERR_FILE_NOT_FOUND:
     1783                        /* We will deal with this down below. */
     1784                        rc = VINF_SUCCESS;
     1785                        break;
     1786                    default:
     1787                        setProgressErrorMsg(VBOX_E_IPRT_ERROR,
     1788                                            Utf8StrFmt(GuestSession::tr("Querying information on for '%s' failed: %Rrc"),
     1789                                            strDstRootAbs.c_str(), rcGuest));
     1790                        break;
     1791                }
     1792            }
     1793            else
     1794            {
     1795                setProgressErrorMsg(VBOX_E_IPRT_ERROR,
     1796                                    Utf8StrFmt(GuestSession::tr("Querying information on guest for '%s' failed: %Rrc"),
     1797                                               strDstRootAbs.c_str(), rc));
     1798                break;
     1799            }
     1800        }
     1801
     1802        LogFlowFunc(("List inital: rc=%Rrc, srcRootAbs=%s, dstRootAbs=%s\n",
     1803                     rc, strSrcRootAbs.c_str(), strDstRootAbs.c_str()));
     1804
     1805        /* Calculated file copy flags for the current source spec. */
     1806        FileCopyFlag_T fFileCopyFlags = FileCopyFlag_None;
    18251807
    18261808        /* Create the root directory. */
     
    18301812            fFollowSymlinks   = pList->mSourceSpec.Type.Dir.fFollowSymlinks;
    18311813
    1832             if (pList->mSourceSpec.fDryRun == false)
    1833             {
    1834                 rc = directoryCreateOnGuest(pList->mDstRootAbs, DirectoryCreateFlag_None, fDirMode,
    1835                                             fFollowSymlinks, fCopyIntoExisting);
    1836                 if (RT_FAILURE(rc))
    1837                     break;
    1838             }
     1814            LogFlowFunc(("Directory: fDirCopyFlags=%#x, fCopyIntoExisting=%RTbool, fFollowSymlinks=%RTbool\n",
     1815                         pList->mSourceSpec.Type.Dir.fCopyFlags, fCopyIntoExisting, fFollowSymlinks));
     1816
     1817            /* If the directory on the guest already exists, append the name of the root source directory to it. */
     1818            if (dstObjData.mType == FsObjType_Directory)
     1819            {
     1820                if (fCopyIntoExisting)
     1821                {
     1822                    if (   !strDstRootAbs.endsWith("/")
     1823                        && !strDstRootAbs.endsWith("\\"))
     1824                        strDstRootAbs += "/";
     1825                    strDstRootAbs += Utf8Str(RTPathFilenameEx(strSrcRootAbs.c_str(), mfPathStyle));
     1826                }
     1827                else
     1828                {
     1829                    setProgressErrorMsg(VBOX_E_IPRT_ERROR,
     1830                                        Utf8StrFmt(GuestSession::tr("Guest directory \"%s\" already exists"),
     1831                                                   strDstRootAbs.c_str()));
     1832                    rc = VERR_ALREADY_EXISTS;
     1833                }
     1834            }
     1835
     1836            /* Make sure the destination root directory exists. */
     1837            if (   RT_SUCCESS(rc)
     1838                && pList->mSourceSpec.fDryRun == false)
     1839            {
     1840                rc = directoryCreateOnGuest(strDstRootAbs, DirectoryCreateFlag_None, fDirMode,
     1841                                            fFollowSymlinks, true /* fCanExist */);
     1842            }
     1843
     1844            /* No tweaking of fFileCopyFlags needed here. */
    18391845        }
    18401846        else if (pList->mSourceSpec.enmType == FsObjType_File)
     
    18421848            fCopyIntoExisting = !(pList->mSourceSpec.Type.File.fCopyFlags & FileCopyFlag_NoReplace);
    18431849            fFollowSymlinks   = RT_BOOL(pList->mSourceSpec.Type.File.fCopyFlags & FileCopyFlag_FollowLinks);
     1850
     1851            LogFlowFunc(("File: fFileCopyFlags=%#x, fCopyIntoExisting=%RTbool, fFollowSymlinks=%RTbool\n",
     1852                         pList->mSourceSpec.Type.File.fCopyFlags, fCopyIntoExisting, fFollowSymlinks));
     1853
     1854            fFileCopyFlags = pList->mSourceSpec.Type.File.fCopyFlags; /* Just use the flags directly from the spec. */
    18441855        }
    18451856        else
    1846             AssertFailed();
     1857            AssertFailedStmt(rc = VERR_NOT_SUPPORTED);
     1858
     1859        if (RT_FAILURE(rc))
     1860            break;
     1861
     1862        LogFlowFunc(("List final: rc=%Rrc, srcRootAbs=%s, dstRootAbs=%s, fFileCopyFlags=%#x\n",
     1863                     rc, strSrcRootAbs.c_str(), strDstRootAbs.c_str(), fFileCopyFlags));
     1864
     1865        LogRel2(("Guest Control: Copying '%s' from host to '%s' on guest ...\n", strSrcRootAbs.c_str(), strDstRootAbs.c_str()));
    18471866
    18481867        FsEntries::const_iterator itEntry = pList->mVecEntries.begin();
    1849         while (itEntry != pList->mVecEntries.end())
     1868        while (   RT_SUCCESS(rc)
     1869               && itEntry != pList->mVecEntries.end())
    18501870        {
    18511871            FsEntry *pEntry = *itEntry;
    18521872            AssertPtr(pEntry);
    18531873
    1854             Utf8Str strSrcAbs = pList->mSrcRootAbs;
    1855             Utf8Str strDstAbs = pList->mDstRootAbs;
     1874            Utf8Str strSrcAbs = strSrcRootAbs;
     1875            Utf8Str strDstAbs = strDstRootAbs;
     1876
    18561877            if (pList->mSourceSpec.enmType == FsObjType_Directory)
    18571878            {
     1879                if (   !strSrcAbs.endsWith("/")
     1880                    && !strSrcAbs.endsWith("\\"))
     1881                    strSrcAbs += "/";
    18581882                strSrcAbs += pEntry->strPath;
     1883            }
     1884
     1885            /** @todo Handle stuff like "C:" for destination, where the destination will be the CWD for drive C. */
     1886            if (dstObjData.mType == FsObjType_Directory)
     1887            {
     1888                if (   !strDstAbs.endsWith("/")
     1889                    && !strDstAbs.endsWith("\\"))
     1890                    strDstAbs += "/";
    18591891                strDstAbs += pEntry->strPath;
    18601892            }
     
    18621894            mProgress->SetNextOperation(Bstr(strSrcAbs).raw(), 1);
    18631895
     1896            LogFlowFunc(("strEntry='%s'\n", pEntry->strPath.c_str()));
     1897            LogFlowFunc(("\tsrcAbs='%s'\n", strSrcAbs.c_str()));
     1898            LogFlowFunc(("\tdstAbs='%s'\n", strDstAbs.c_str()));
     1899
    18641900            switch (pEntry->fMode & RTFS_TYPE_MASK)
    18651901            {
    18661902                case RTFS_TYPE_DIRECTORY:
    1867                     LogFlowFunc(("Directory '%s': %s -> %s\n", pEntry->strPath.c_str(), strSrcAbs.c_str(), strDstAbs.c_str()));
     1903                {
    18681904                    if (!pList->mSourceSpec.fDryRun)
    1869                     {
    18701905                        rc = directoryCreateOnGuest(strDstAbs, DirectoryCreateFlag_None, fDirMode,
    18711906                                                    fFollowSymlinks, fCopyIntoExisting);
    1872                         if (RT_FAILURE(rc))
    1873                             break;
    1874                     }
    18751907                    break;
     1908                }
    18761909
    18771910                case RTFS_TYPE_FILE:
    1878                     LogFlowFunc(("File '%s': %s -> %s\n", pEntry->strPath.c_str(), strSrcAbs.c_str(), strDstAbs.c_str()));
     1911                {
    18791912                    if (!pList->mSourceSpec.fDryRun)
    1880                         rc = fileCopyToGuest(strSrcAbs, strDstAbs, pList->mSourceSpec.Type.File.fCopyFlags);
     1913                        rc = fileCopyToGuest(strSrcAbs, strDstAbs, fFileCopyFlags);
    18811914                    break;
     1915                }
    18821916
    18831917                default:
    1884                     LogFlowFunc(("Warning: Type %d for '%s' is not supported\n",
    1885                                  pEntry->fMode & RTFS_TYPE_MASK, strSrcAbs.c_str()));
     1918                    LogRel2(("Guest Control: Warning: Type 0x%x for '%s' is not supported, skipping\n",
     1919                             pEntry->fMode & RTFS_TYPE_MASK, strSrcAbs.c_str()));
    18861920                    break;
    18871921            }
  • trunk/src/VBox/ValidationKit/tests/additions/tdAddGuestCtrl.py

    r83310 r83336  
    13541354            'update_additions'
    13551355        ];
    1356         self.asTests        = self.asTestsDef;
     1356        self.asTests        = 'copy_to'; # self.asTestsDef;
    13571357        self.fSkipKnownBugs = False;
    13581358        self.oTestFiles     = None  # type: vboxtestfileset.TestFileSet
     
    15301530        #
    15311531        cchGst = len(self.getGuestTempDir(oTestVm)) + 1 + len('addgst-1') + 1;
    1532         cchHst = len(self.oTstDrv.sScratchPath) + 1 + len('cp2/addgst-1') + 1;
     1532        cchHst = len(self.oTstDrv.sScratchPath) + 1 + len('copyto/addgst-1') + 1;
    15331533        cchMaxPath = 230;
    15341534        if cchHst > cchGst:
     
    43184318        # Paths and test files.
    43194319        #
    4320         sScratchHst             = os.path.join(self.oTstDrv.sScratchPath,         'cp2');
     4320        sScratchHst             = os.path.join(self.oTstDrv.sScratchPath,         'copyto');
    43214321        sScratchTestFilesHst    = os.path.join(sScratchHst, self.oTestFiles.sSubDir);
    43224322        sScratchEmptyDirHst     = os.path.join(sScratchTestFilesHst, self.oTestFiles.oEmptyDir.sName);
     
    43244324        sScratchTreeDirHst      = os.path.join(sScratchTestFilesHst, self.oTestFiles.oTreeDir.sName);
    43254325
    4326         sScratchGst             = oTestVm.pathJoin(self.getGuestTempDir(oTestVm), 'cp2');
     4326        sScratchGst             = oTestVm.pathJoin(self.getGuestTempDir(oTestVm), 'copyto');
    43274327        sScratchDstDir1Gst      = oTestVm.pathJoin(sScratchGst, 'dstdir1');
    43284328        sScratchDstDir2Gst      = oTestVm.pathJoin(sScratchGst, 'dstdir2');
     
    44614461        if self.oTstDrv.fpApiVer > 5.2: # Copying directories via Main is supported only in versions > 5.2.
    44624462            atTests.extend([
    4463                 [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir1Gst),   tdTestResultSuccess() ],
     4463                [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir1Gst,
     4464                                  afFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting]),  tdTestResultSuccess() ],
     4465                # Try again.
     4466                [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir1Gst,
     4467                                  afFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting]),  tdTestResultSuccess() ],
     4468                # Should fail, as destination directory already exists.
    44644469                [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir1Gst),   tdTestResultFailure() ],
    4465                 [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir1Gst,
    4466                                  afFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting]),    tdTestResultSuccess() ],
    44674470                # Try again with trailing slash, should yield the same result:
    4468                 [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir2Gst + oTestVm.pathSep()),
    4469                   tdTestResultSuccess() ],
     4471                [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir2Gst + oTestVm.pathSep(),
     4472                                  afFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting]),  tdTestResultSuccess() ],
     4473                # Try again.
     4474                [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir2Gst + oTestVm.pathSep(),
     4475                                  afFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting]),  tdTestResultSuccess() ],
     4476                # Should fail, as destination directory already exists.
    44704477                [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir2Gst + oTestVm.pathSep()),
    44714478                  tdTestResultFailure() ],
    4472                 [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir2Gst + oTestVm.pathSep(),
    4473                                   afFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting]),
     4479                # Copy with a different destination name just for the heck of it:
     4480                [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = oTestVm.pathJoin(sScratchDstDir1Gst, 'empty2')),
    44744481                  tdTestResultSuccess() ],
    44754482            ]);
    4476             if not self.fSkipKnownBugs:
    4477                 atTests.extend([
    4478                     # Copy with a different destination name just for the heck of it:
    4479                     [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = oTestVm.pathJoin(sScratchDstDir1Gst, 'empty2')),
    4480                       tdTestResultSuccess() ],
    4481                 ]);
    44824483            atTests.extend([
    44834484                # Now the same using a directory with files in it:
    4484                 [ tdTestCopyToDir(sSrc = sScratchNonEmptyDirHst, sDst = sScratchDstDir3Gst),    tdTestResultSuccess() ],
    4485                 [ tdTestCopyToDir(sSrc = sScratchNonEmptyDirHst, sDst = sScratchDstDir3Gst),    tdTestResultFailure() ],
     4485                [ tdTestCopyToDir(sSrc = sScratchNonEmptyDirHst, sDst = sScratchDstDir3Gst,
     4486                                  afFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting]),   tdTestResultSuccess() ],
     4487                # Again.
     4488                [ tdTestCopyToDir(sSrc = sScratchNonEmptyDirHst, sDst = sScratchDstDir3Gst,
     4489                                  afFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting]),   tdTestResultSuccess() ],
     4490                # Should fail, as directory is existing already.
     4491                [ tdTestCopyToDir(sSrc = sScratchNonEmptyDirHst, sDst = sScratchDstDir3Gst), tdTestResultFailure() ],
    44864492            ]);
    4487             if not self.fSkipKnownBugs:
    4488                 atTests.extend([
    4489                     [ tdTestCopyToDir(sSrc = sScratchNonEmptyDirHst, sDst = sScratchDstDir3Gst,
    4490                                       afFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting]),   tdTestResultSuccess() ],
    4491                 ]);
    44924493            atTests.extend([
    4493                 #[ tdTestRemoveGuestDir(sScratchDstDir2Gst, tdTestResult() ],
    44944494                # Copy the entire test tree:
    4495                 [ tdTestCopyToDir(sSrc = sScratchTreeDirHst, sDst = sScratchDstDir4Gst), tdTestResultSuccess() ],
    4496                 #[ tdTestRemoveGuestDir(sScratchDstDir3Gst, tdTestResult() ],
     4495                [ tdTestCopyToDir(sSrc = sScratchTreeDirHst, sDst = sScratchDstDir4Gst,
     4496                                  afFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting]), tdTestResultSuccess() ],
    44974497            ]);
    44984498
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette